From 3360309b71a2e97ebcc4a1f425bc98b59ae9fdc9 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 1 Mar 2014 13:11:06 +0100 Subject: add df MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- examples/plugin-test | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/plugin-test b/examples/plugin-test index 145fcec..c68065e 100644 --- a/examples/plugin-test +++ b/examples/plugin-test @@ -9,6 +9,7 @@ from plugins.loadavg import AverageLoad from plugins.users import Users from plugins.pacman import Pacman from plugins.uname import Uname +from plugins.df import Discs OUTPUT, HEIGHT, YPOS, TOP = 0, 24, 24, True @@ -82,7 +83,30 @@ def redraw(): uname = '%s %s %s' uname %= (nodename, kernel_release, operating_system) - text = '%s │ %s │ %s │ %s │ %s │ %s' - text %= (time, uptime, idle, loadavg, users, uname) + discs_ = Discs() + discs = [] + for fs in discs_.filesystems: + if '/' not in fs: + continue + disc = discs_.filesystems[fs] + mp = disc.mountpoint + if mp in ['/boot', '/rescue']: + continue + mp = mp.split('/')[-1] + if mp == '': + mp = '/' + use = disc.used * 100 / disc.blocks + colour, colour_ = '39', '39' + if use < 50: colour = '32' + if use > 75: colour = '33' + if use > 95: colour = '31' + if use > 99: colour, colour_ = '31', '31' + discs.append((mp, use, colour, colour_)) + discs.sort(key = lambda d : d[0]) + discs = ['\033[%sm%s:\033[%sm%.1f\033[0m%%' % (d[3], d[0], d[2], d[1]) for d in discs] + discs = 'df: %s' % ' '.join(discs) + + text = '%s │ %s │ %s │ %s │ %s │ %s\n%s' + text %= (time, uptime, idle, loadavg, users, uname, discs) bar.draw_coloured_text(0, 10, 0, 2, text) -- cgit v1.2.3-70-g09d2