From 015bdb9e386ac2b0cef9a280f00cd81990e2b732 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 28 Feb 2014 21:21:54 +0100 Subject: add users MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- examples/plugin-test | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/plugin-test b/examples/plugin-test index 301c99c..ba4d823 100644 --- a/examples/plugin-test +++ b/examples/plugin-test @@ -2,9 +2,11 @@ # A simple xpybar configuration example that tests the plugins +import os from plugins.uptime import Uptime from plugins.loadavg import AverageLoad +from plugins.users import Users OUTPUT, HEIGHT, YPOS, TOP = 0, 24, 24, True @@ -26,7 +28,18 @@ def redraw(): tot_tasks = loadavg_.total_tasks last_pid = loadavg_.last_pid - text = 'Uptime: %s │ Idle time: %s %s │ Average load: %2i%% %2i%% %2i%% %i/%i %i' - text %= (uptime, tot_idle, avg_idle, avg_5, avg_10, avg_15, act_tasks, tot_tasks, last_pid) + users_ = Users().users + you = os.environ['USER'] + def colour_user(user): + if user == 'root': + return '\033[31m%s\033[39m' + elif not user == you: + return '\033[33m%s\033[39m' + else: + return '%s' + users = ' '.join(['%s{%i}' % (colour_user(u) % u, len(users_[u])) for u in users_.keys()]) + + text = 'Uptime: %s │ Idle time: %s %s │ Average load: %2i%% %2i%% %2i%% %i/%i %i │ Users: %s' + text %= (uptime, tot_idle, avg_idle, avg_5, avg_10, avg_15, act_tasks, tot_tasks, last_pid, users) bar.draw_coloured_text(0, 10, 0, 2, text) -- cgit v1.2.3-70-g09d2