diff options
| author | Mattias Andrée <maandree@operamail.com> | 2014-02-28 21:21:54 +0100 | 
|---|---|---|
| committer | Mattias Andrée <maandree@operamail.com> | 2014-02-28 21:21:54 +0100 | 
| commit | 015bdb9e386ac2b0cef9a280f00cd81990e2b732 (patch) | |
| tree | 15eddb9eea071d2952c691318b0213575d217592 /examples | |
| parent | m (diff) | |
| download | xpybar-015bdb9e386ac2b0cef9a280f00cd81990e2b732.tar.gz xpybar-015bdb9e386ac2b0cef9a280f00cd81990e2b732.tar.bz2 xpybar-015bdb9e386ac2b0cef9a280f00cd81990e2b732.tar.xz  | |
add users
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/plugin-test | 17 | 
1 files changed, 15 insertions, 2 deletions
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)  | 
