import os

from i3pystatus import IntervalModule
from .core.util import round_dict


class Disk(IntervalModule):

    """
    Gets `{used}`, `{free}`, `{available}` and `{total}` amount of bytes on the given mounted filesystem.

    These values can also be expressed in percentages with the `{percentage_used}`, `{percentage_free}`
    and `{percentage_avail}` formats.
    """

    settings = (
        "format", "path",
        ("divisor", "divide all byte values by this value, commonly 1024**3 (gigabyte)"),
    )
    required = ("path",)
    color = "#FFFFFF"
    format = "{free}/{avail}"
    divisor = 1024 ** 3

    def run(self):
        stat = os.statvfs(self.path)
        cdict = {
            "total": (stat.f_bsize * stat.f_blocks) / self.divisor,
            "free": (stat.f_bsize * stat.f_bfree) / self.divisor,
            "avail": (stat.f_bsize * stat.f_bavail) / self.divisor,
            "used": (stat.f_bsize * (stat.f_blocks - stat.f_bfree)) / self.divisor,
            "percentage_free": stat.f_bfree / stat.f_blocks * 100,
            "percentage_avail": stat.f_bavail / stat.f_blocks * 100,
            "percentage_used": (stat.f_blocks - stat.f_bfree) / stat.f_blocks * 100,
        }
        round_dict(cdict, 2)

        self.output = {
            "full_text": self.format.format(**cdict),
            "color": self.color
        }

@@ -510,14 +510,221 @@
 %22),%0A
+        (%22display_limit%22, %22limit upper witch one the module isn't display%22),%0A        (%22critical_limit%22, %22limit under witch one the disk space is critical%22),%0A        (%22critical_color%22, %22the critical color%22),%0A
     )%0A
-
     
@@ -766,16 +766,47 @@
 FFFFFF%22%0A
+    critical_color = %22#FF0000%22%0A
     form
@@ -850,16 +850,72 @@
 024 ** 3
+%0A    display_limit = float('Inf')%0A    critical_limit = 0
 %0A%0A    de
@@ -964,16 +964,175 @@
 f.path)%0A
+        available = (stat.f_bsize * stat.f_bavail) / self.divisor%0A%0A        if available %3E self.display_limit:%0A            self.output = %7B%7D%0A            return%0A%0A
         
@@ -1300,53 +1300,17 @@
 l%22: 
-(stat.f_bsize * stat.f_bavail) / self.divisor
+available
 ,%0A  
@@ -1730,16 +1730,16 @@
 cdict),%0A
-
         
@@ -1761,16 +1761,131 @@
 lf.color
+ if available %3E self.critical_limit else self.critical_color,%0A            %22urgent%22: available %3E self.critical_limit
 %0A       

Add display and critical limit in the disk module