diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-03-01 20:13:30 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-03-01 20:13:30 +0100 |
commit | 83d11884fb4d5876c98a5404c83630a76a695a22 (patch) | |
tree | e8476aeaed6fd15b48f7ca3a351c9186d10ca117 /examples | |
parent | add total disc usage in example (diff) | |
download | xpybar-83d11884fb4d5876c98a5404c83630a76a695a22.tar.gz xpybar-83d11884fb4d5876c98a5404c83630a76a695a22.tar.bz2 xpybar-83d11884fb4d5876c98a5404c83630a76a695a22.tar.xz |
add mem
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/plugin-test | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/examples/plugin-test b/examples/plugin-test index e27aac4..d29b5a7 100644 --- a/examples/plugin-test +++ b/examples/plugin-test @@ -10,6 +10,7 @@ from plugins.users import Users from plugins.pacman import Pacman from plugins.uname import Uname from plugins.df import Discs +from plugins.mem import Memory OUTPUT, HEIGHT, YPOS, TOP = 0, 24, 24, True @@ -83,6 +84,17 @@ def redraw(): uname = '%s %s %s' uname %= (nodename, kernel_release, operating_system) + memory_ = Memory() + def colourise(value, format = '%.0f'): + colour = '39' + if value > 30: colour = '32' + if value > 50: colour = '33' + if value > 80: colour = '31' + return '\033[%sm%s%%\033[0m' % (colour, format % value) + mem = 'Mem: ' + colourise(memory_.mem_used * 100 / memory_.mem_total) + swp = 'Swp: ' + colourise(memory_.swap_used * 100 / memory_.swap_total) + shm = 'Shm: ' + colourise(memory_.shmem * 100 / memory_.mem_total) + discs_ = Discs() discs = [] discs_used = 0 @@ -116,7 +128,7 @@ 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\n%s' - text %= (time, uptime, idle, loadavg, users, uname, discs) + text = '%s │ %s │ %s │ %s │ %s │ %s │ %s │ %s │ %s\n%s' + text %= (time, uptime, idle, loadavg, users, uname, mem, swp, shm, discs) bar.draw_coloured_text(0, 10, 0, 2, text) |