aboutsummaryrefslogtreecommitdiffstats
path: root/examples/plugin-test
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-03-01 13:11:06 +0100
committerMattias Andrée <maandree@operamail.com>2014-03-01 13:11:06 +0100
commit3360309b71a2e97ebcc4a1f425bc98b59ae9fdc9 (patch)
treee0cf37a290c9bc5de155550eeb14a4110ccb1f6f /examples/plugin-test
parentadd uptime and idle time in seconds format (diff)
downloadxpybar-3360309b71a2e97ebcc4a1f425bc98b59ae9fdc9.tar.gz
xpybar-3360309b71a2e97ebcc4a1f425bc98b59ae9fdc9.tar.bz2
xpybar-3360309b71a2e97ebcc4a1f425bc98b59ae9fdc9.tar.xz
add df
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'examples/plugin-test')
-rw-r--r--examples/plugin-test28
1 files changed, 26 insertions, 2 deletions
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)