diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-03-01 21:07:57 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-03-01 21:07:57 +0100 |
commit | 8049a8733933ef586d6d49279a291ba367b38625 (patch) | |
tree | 06170b4746d808979b9335df07aa67763a82391f /examples | |
parent | add mem (diff) | |
download | xpybar-8049a8733933ef586d6d49279a291ba367b38625.tar.gz xpybar-8049a8733933ef586d6d49279a291ba367b38625.tar.bz2 xpybar-8049a8733933ef586d6d49279a291ba367b38625.tar.xz |
add discstats
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/plugin-test | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/examples/plugin-test b/examples/plugin-test index d29b5a7..3fce9bc 100644 --- a/examples/plugin-test +++ b/examples/plugin-test @@ -11,6 +11,7 @@ from plugins.pacman import Pacman from plugins.uname import Uname from plugins.df import Discs from plugins.mem import Memory +from plugins.discstats import DiscStats OUTPUT, HEIGHT, YPOS, TOP = 0, 24, 24, True @@ -128,7 +129,23 @@ def redraw(): if use > 99: colour = '41;33' discs = 'df: %s : \033[%sm%.2f\033[0m%%' % (' '.join(discs), colour, use) - text = '%s │ %s │ %s │ %s │ %s │ %s │ %s │ %s │ %s\n%s' - text %= (time, uptime, idle, loadavg, users, uname, mem, swp, shm, discs) + discstats_ = DiscStats() + discstats = [] + for disc in discstats_.devices.keys(): + if disc.startswith('sd') or disc.startswith('hd'): + disc = discstats_.devices[disc] + discstats.append((disc.device, disc.io_current)) + def colourise(value): + colour = '39' + if value >= 1: colour = '32' + if value >= 3: colour = '33' + if value >= 5: colour = '31' + return '\033[%sm%i\033[0m' % (colour, value) + discstats.sort(key = lambda x : x[0]) + discstats = ['%s:%s' % (d[2:], colourise(i)) for d, i in discstats] + discstats = 'Disc stats: %s' % (' '.join(discstats)) + + text = '%s │ %s │ %s │ %s │ %s │ %s │ %s │ %s │ %s\n%s │ %s' + text %= (time, uptime, idle, loadavg, users, uname, mem, swp, shm, discs, discstats) bar.draw_coloured_text(0, 10, 0, 2, text) |