diff --git a/i3pystatus/openfiles.py b/i3pystatus/openfiles.py new file mode 100644 index 0000000..0afb43e --- /dev/null +++ b/i3pystatus/openfiles.py @@ -0,0 +1,30 @@ +from i3pystatus import IntervalModule + + +class Openfiles(IntervalModule): + """ + Displays the current/max open files. + """ + + settings = ( + ("filenr_path", "Location to file-nr (usually /proc/sys/fs/file-nr"), + "color", + "format" + ) + color = 'FFFFFF' + interval = 30 + filenr_path = '/proc/sys/fs/file-nr' + format = "open/max: {openfiles}/{maxfiles}" + + def run(self): + + cur_filenr = open(self.filenr_path, 'r').readlines() + openfiles, unused, maxfiles = cur_filenr[0].split() + + cdict = {'openfiles': openfiles, + 'maxfiles': maxfiles} + + self.output = { + "full_text": self.format.format(**cdict), + "color": self.color + }