From 4a6fecc5da9b2a5b00c5a287c66839de55a68c23 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 6 Jun 2014 02:28:26 +0200 Subject: m MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- examples/moderate | 11 +---------- src/plugins/cpu.py | 24 ++++++++++++------------ src/plugins/xdisplay.py | 6 ++++-- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/examples/moderate b/examples/moderate index f25cbb1..905fe01 100644 --- a/examples/moderate +++ b/examples/moderate @@ -14,7 +14,6 @@ from plugins.pacman import Pacman from plugins.uname import Uname from plugins.weather import Weather from plugins.chase import Chase -from plugins.solar import Solar OUTPUT, YPOS, TOP = 0, 24, True @@ -205,27 +204,19 @@ def chase(): return '\033[%smChase\033[0m' % status -solar_ = os.environ['HOME'] + '/.xpybar.sun' -def sun(): - try: - return 'Sun: %s' % Solar(solar_).output - except: - return '¿Cannot get solar information?' - functions = [ Sometimes(lambda : clock_.read(), 1 * 2), lambda : time.time() % 1, Sometimes(users, 1 * 2), weather, chase, - Sometimes(sun, 1 * 2), cpu, memory, network, Sometimes(uname, 30 * 60 * 2), ] -pattern = [ '%s │ %.2f │ %s │ %s │ %s │ %s }{ %s │ %s │ %s │ %s' +pattern = [ '%s │ %.2f │ %s │ %s │ %s }{ %s │ %s │ %s │ %s' ] diff --git a/src/plugins/cpu.py b/src/plugins/cpu.py index 2305e89..3b23ecd 100644 --- a/src/plugins/cpu.py +++ b/src/plugins/cpu.py @@ -22,22 +22,22 @@ class CPU: ''' Retrieve processor statistics - @variable cpu_total:list Accumulative processors statistics - @variable cpus:list> Individual processors statistics - @variable intr:list Counts of individual interrupts serviced since boot time - @variable intr_total:int Sum of `intr` - @variable ctxt:int The number of context switches that the system underwent. - @variable btime:int Boot time, in seconds since the Epoch, 1970-01-01 00:00:00 UTC - @variable processes:int Number of forks and clones (and similar) created since boot - @variable procs_running:int? Number of processes in runnable state (linux>=2.5.45) - @variable procs_blocked:int? Number of processes blocked waiting for I/O to complete (linux>=2.5.45) - @variable softirq:list? Counts of individual software IRQ since boot time - @variable softirq_total:int? Sum of `softirq` + @variable cpu_total:list Accumulative processors statistics + @variable cpus:list> Individual processors statistics + @variable intr:list Counts of individual interrupts serviced since boot time + @variable intr_total:int Sum of `intr` + @variable ctxt:int The number of context switches that the system underwent. + @variable btime:int Boot time, in seconds since the Epoch, 1970-01-01 00:00:00 UTC + @variable processes:int Number of forks and clones (and similar) created since boot + @variable procs_running:int? Number of processes in runnable state (linux>=2.5.45) + @variable procs_blocked:int? Number of processes blocked waiting for I/O to complete (linux>=2.5.45) + @variable softirq:list? Counts of individual software IRQ since boot time + @variable softirq_total:int? Sum of `softirq` @variable fields:dict> Table with all information ''' - # These contants are index in the CPU statistcs, use for example `CPU_instance.cpu[CPU.user]` + # These constants are index in the CPU statistcs, use for example `CPU_instance.cpu[CPU.user]` user = 0 ''' diff --git a/src/plugins/xdisplay.py b/src/plugins/xdisplay.py index 907b6bf..6f4bf7e 100644 --- a/src/plugins/xdisplay.py +++ b/src/plugins/xdisplay.py @@ -50,10 +50,12 @@ class XDisplay: self.display = None self.screen = None else: - self.host = self.connection.split(':')[0] + self.host = self.connection.split(':')[:-1] + if self.host.startswith('[') and self.host.endswith(']'): + self.host = self.host[1 : -1] if self.host == '': self.host = None - self.display, self.screen = (self.connection.split(':')[1] + '.').split('.')[:2] + self.display, self.screen = (self.connection.split(':')[-1] + '.').split('.')[:2] self.display = int(self.display) self.screen = None if self.screen == '' else int(self.screen) r = get_screen().root -- cgit v1.2.3-70-g09d2