diff options
Diffstat (limited to '')
-rw-r--r-- | examples/plugins/cpuonline | 2 | ||||
-rw-r--r-- | examples/plugins/moc | 6 | ||||
-rw-r--r-- | examples/plugins/ropty | 13 | ||||
-rw-r--r-- | src/plugins/cpuonline.py | 3 |
4 files changed, 13 insertions, 11 deletions
diff --git a/examples/plugins/cpuonline b/examples/plugins/cpuonline index 1f99478..8853204 100644 --- a/examples/plugins/cpuonline +++ b/examples/plugins/cpuonline @@ -13,7 +13,7 @@ OUTPUT, HEIGHT, YPOS, TOP = 0, 12, 24, True def redraw(): cpu = CPUOnline() - s = lambda cpus : ', '.join([str(i) for i in cpus]) + s = lambda cpus : '(none)' if len(cpus) == 0 else ', '.join([str(i) for i in cpus]) text = 'Online: %s │ Offline: %s │ Present: %s │ Possible: %s' text %= s(cpu.online), s(cpu.offline), s(cpu.present), s(cpu.possible) bar.clear() diff --git a/examples/plugins/moc b/examples/plugins/moc index 414323e..b572186 100644 --- a/examples/plugins/moc +++ b/examples/plugins/moc @@ -9,7 +9,7 @@ from plugins.moc import MOC from plugins.clock import Clock -OUTPUT, HEIGHT, YPOS, TOP = 0, 12, 24, True +OUTPUT, HEIGHT, YPOS, TOP = 0, 24, 24, True clock = Clock(sync_to = Clock.SECONDS) @@ -20,15 +20,17 @@ def start(): async(lambda : clock.continuous_sync(lambda : bar.invalidate())) +line2 = ['File', 'Title', 'SongTitle', 'Album', 'Artist'] def redraw(): moc_ = MOC() text = '' if moc_.state in [MOC.PAUSED, MOC.PLAYING]: - text = ' │ ' + ' │ '.join(['%s: %s' % (key, moc_[keys]) for key in moc_.keys()]) + text = ' │ ' + ' │ '.join(['%s: %s' % (key, moc_[key]) for key in moc_.keys() if key not in line2]) text = 'State: %s%s' % ({MOC.NOT_RUNNING : 'not running', MOC.STOPPED : 'stopped', MOC.PAUSED : 'paused', MOC.PLAYING : 'playing'}[moc_.state], text) + text += '\n' + ' │ '.join(['%s: %s' % (key, moc_[key]) for key in moc_.keys() if key in line2]) bar.clear() bar.draw_coloured_text(0, 10, 0, 2, text) diff --git a/examples/plugins/ropty b/examples/plugins/ropty index 5e41351..8c9c845 100644 --- a/examples/plugins/ropty +++ b/examples/plugins/ropty @@ -1,6 +1,6 @@ # -*- python -*- -# A xpybar configuration example testing the features of plugins.kmsg +# A xpybar configuration example testing the features of plugins.ropty from plugins.ropty import ROPTY @@ -15,12 +15,11 @@ def start(): global pty_ start_() def refresh(): - if pty_.size() == 0: - text = '' - else: - line = pty_.next - text = '\033[37;41m%i\033[00m%s' - text %= (pty_.size(), line) + global text + line = pty_.next() + if line == '': + return + text = '\033[37;41m%i\033[00m%s' % (pty_.size(), line.replace('\x07', '')) bar.invalidate() pty_ = ROPTY(refresh) diff --git a/src/plugins/cpuonline.py b/src/plugins/cpuonline.py index 2dd7d42..5c063d6 100644 --- a/src/plugins/cpuonline.py +++ b/src/plugins/cpuonline.py @@ -43,12 +43,13 @@ class CPUOnline: data = [] for filename in ('offline', 'online', 'possible', 'present'): - with open('/sys/devices/system/cpu/online', 'rb') as file: + with open('/sys/devices/system/cpu/' + filename, 'rb') as file: data.append(file.read()) data = [x.decode('utf-8', 'replace').replace('\n', ' ').replace(',', ' ') for x in data] data = [map(expand, filter(lambda item : not item == '', x.split(' '))) for x in data] data = [reduce(lambda x, y : x + y, list(x)) for x in data] + data = [x if x is not None else [] for x in data] (self.offline, self.online, self.possible, self.present) = data |