diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-03-01 13:43:40 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-03-01 13:44:41 +0100 |
commit | ed4bd68222dec9c9a2a03d5e2c710de984835b4d (patch) | |
tree | f6b7c8008a532cb35c7bde3df602e9eaff6ef772 | |
parent | m (diff) | |
download | xpybar-ed4bd68222dec9c9a2a03d5e2c710de984835b4d.tar.gz xpybar-ed4bd68222dec9c9a2a03d5e2c710de984835b4d.tar.bz2 xpybar-ed4bd68222dec9c9a2a03d5e2c710de984835b4d.tar.xz |
add total disc usage in example
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | examples/plugin-test | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/examples/plugin-test b/examples/plugin-test index 0639c02..e27aac4 100644 --- a/examples/plugin-test +++ b/examples/plugin-test @@ -85,6 +85,8 @@ def redraw(): discs_ = Discs() discs = [] + discs_used = 0 + discs_total = 0 for fs in discs_.filesystems: if '/' not in fs: continue @@ -95,6 +97,8 @@ def redraw(): mp = mp.split('/')[-1] if mp == '': mp = '/' + discs_used += disc.used + discs_total += disc.blocks use = disc.used * 100 / disc.blocks colour, colour_ = '39', '39' if use < 50: colour = '32' @@ -104,7 +108,13 @@ def redraw(): discs.append((mp, use, colour, colour_)) discs.sort(key = lambda d : d[0]) discs = ['\033[%sm%s:\033[%sm%.1f\033[%sm%%\033[0m' % (d[3], d[0], d[2], d[1], d[3]) for d in discs] - discs = 'df: %s' % ' '.join(discs) + use = discs_used * 100 / discs_total + colour = '39' + if use < 50: colour = '32' + if use > 75: colour = '33' + if use > 95: colour = '31' + 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) |