aboutsummaryrefslogtreecommitdiffstats
path: root/examples/plugin-test
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-03-01 12:01:17 +0100
committerMattias Andrée <maandree@operamail.com>2014-03-01 12:01:17 +0100
commit4855300f98ab9ffe393b2aa26c3d22b2dd9f4636 (patch)
treeba6a3b2a45142457df3fcace6fb1f145a59c136a /examples/plugin-test
parentadd uname (diff)
downloadxpybar-4855300f98ab9ffe393b2aa26c3d22b2dd9f4636.tar.gz
xpybar-4855300f98ab9ffe393b2aa26c3d22b2dd9f4636.tar.bz2
xpybar-4855300f98ab9ffe393b2aa26c3d22b2dd9f4636.tar.xz
add pacman
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--examples/plugin-test30
1 files changed, 30 insertions, 0 deletions
diff --git a/examples/plugin-test b/examples/plugin-test
index d9ead29..2945e95 100644
--- a/examples/plugin-test
+++ b/examples/plugin-test
@@ -7,6 +7,7 @@ import os
from plugins.uptime import Uptime
from plugins.loadavg import AverageLoad
from plugins.users import Users
+from plugins.pacman import Pacman
from plugins.uname import Uname
@@ -44,10 +45,39 @@ def redraw():
users = ['%s{%i}' % (colour_user(u) % u, len(users_[u])) for u in users_.keys()]
users = 'Users: %s' % (' '.join(users))
+ have_linux_libre, have_pacman = True, True
+ linux_installed, linux_latest = None, None
+ try:
+ linux_installed = Pacman('linux-libre', True)
+ except:
+ have_linux_libre = False
+ try:
+ linux_installed = Pacman('linux', True)
+ except:
+ have_pacman = False
+ if have_pacman:
+ linux_latest = Pacman('linux-libre' if have_linux_libre else 'linux', False)
+
uname_ = Uname()
nodename = uname_.nodename
kernel_release = uname_.kernel_release
operating_system = uname_.operating_system
+ if have_pacman:
+ linux_running = kernel_release.split('-')
+ linux_running, kernel_release = linux_running[:2], linux_running[2:]
+ linux_running = '-'.join(linux_running)
+ kernel_release = '-' + '-'.join(kernel_release)
+ linux_installed = linux_installed.version
+ linux_latest = linux_latest.version
+ if linux_installed == linux_latest:
+ if linux_running == linux_installed:
+ linux_running = '\033[32m%s\033[39m' % linux_running
+ else:
+ if linux_running == linux_installed:
+ linux_running = '\033[33m%s\033[39m' % linux_running
+ else:
+ linux_running = '\033[31m%s\033[39m' % linux_running
+ kernel_release = linux_running + kernel_release
uname = '%s %s %s'
uname %= (nodename, kernel_release, operating_system)