aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-03-03 17:24:15 +0100
committerMattias Andrée <maandree@operamail.com>2014-03-03 17:24:15 +0100
commitaa09c1088ada289f662c6849674ec4f8cbd6956c (patch)
treee5f0a4ce59668337f259a619cc9cbad80a4e8ca3 /examples
parentmisc (diff)
downloadxpybar-aa09c1088ada289f662c6849674ec4f8cbd6956c.tar.gz
xpybar-aa09c1088ada289f662c6849674ec4f8cbd6956c.tar.bz2
xpybar-aa09c1088ada289f662c6849674ec4f8cbd6956c.tar.xz
add network
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--examples/plugin-test19
1 files changed, 16 insertions, 3 deletions
diff --git a/examples/plugin-test b/examples/plugin-test
index 9cf449c..711ef11 100644
--- a/examples/plugin-test
+++ b/examples/plugin-test
@@ -17,9 +17,10 @@ from plugins.xdisplay import XDisplay
from plugins.moc import MOC
from plugins.cpu import CPU
from plugins.clock import Clock
+from plugins.network import Network
-OUTPUT, HEIGHT, YPOS, TOP = 0, 24, 24, True
+OUTPUT, HEIGHT, YPOS, TOP = 0, 3 * 12, 24, True
clock = Clock(format = '%Y-(%m)%b-%d %T, %a w%V, %Z')
@@ -179,9 +180,21 @@ def redraw():
cpu = colourise(cpu_usage(now_cpu_idle, now_cpu_total, last_cpu_idle, last_cpu_total))
cpu = 'Cpu: %s : %s' % (cpus, cpu)
+ gb = lambda x : x / 1024 ** 3
+ net_ = Network('lo').devices
+ net_ = [(dev, gb(net_[dev]['rx_bytes']), gb(net_[dev]['tx_bytes'])) for dev in net_]
+ net_each = ['%s: %.2fGB|%.2fGB' % dev for dev in net_]
+ net_total = '%.2fGB|%.2fGB' % (sum([rx for _, rx, tx in net_]), sum([tx for _, rx, tx in net_]))
+ net = '%s : %s' % (' '.join(net_each), net_total)
- text = '%s │ %s │ %s │ %s │ %s │ %s %s │ %s │ %s │ %s │ %s\n%s │ %s │ %s'
- text %= (date, uptime, idle, loadavg, users, uname, xdisplay, mem, swp, shm, moc, discs, discstats, cpu)
+
+ text = ['%s │ %s │ %s │ %s │ %s │ %s %s │ %s │ %s │ %s │ %s'
+ ,'%s │ %s │ %s'
+ ,'%s']
+ text = '\n'.join(text)
+ text %= (date, uptime, idle, loadavg, users, uname, xdisplay, mem, swp, shm, moc,
+ discs, discstats, cpu,
+ net)
bar.clear()
bar.draw_coloured_text(0, 10, 0, 2, text)