wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 3dd6ee66587c2afb43e939f82028da26eaa8074c
parent 120f5a34a3b99f9c2abc38b6d928b0a95a2904e1
Author: Kris Maglione <jg@suckless.org>
Date:   Tue, 19 May 2009 13:14:06 -0400

Fix Mod-Shift-t in wmiirc.

Diffstat:
alternative_wmiircs/python/pygmi/__init__.py | 7+++++--
alternative_wmiircs/python/pygmi/monitor.py | 21+++++++++++----------
alternative_wmiircs/python/wmiirc | 19+++++++++++--------
cmd/wmii.rc.rc | 4++++
cmd/wmii.sh.sh | 4++++
rc/rc.wmii.rc | 2+-
rc/wmiirc.sh | 2+-
7 files changed, 37 insertions(+), 22 deletions(-)

diff --git a/alternative_wmiircs/python/pygmi/__init__.py b/alternative_wmiircs/python/pygmi/__init__.py @@ -1,4 +1,5 @@ import os +import sys from pyxp import Client @@ -40,8 +41,10 @@ def find_script(name): if os.access('%s/%s' % (path, name), os.X_OK): return '%s/%s' % (path, name) -confpath = os.environ['WMII_CONFPATH'].split(':') -shell = None +confpath = os.environ.get('WMII_CONFPATH', '%s/.wmii' % os.environ['HOME']).split(':') +shell = os.environ['SHELL'] + +sys.path += confpath from pygmi import events, fs, menu, monitor from pygmi.events import * diff --git a/alternative_wmiircs/python/pygmi/monitor.py b/alternative_wmiircs/python/pygmi/monitor.py @@ -53,32 +53,33 @@ class Monitor(object): self.tick() def tick(self): - from pygmi import events mon = monitors.get(self.name, None) - if self.timer and not (events.alive and mon is self): - if client and (not mon or mon is self): - self.button.remove() + if self.timer and mon is not self: return if self.active: from threading import Timer label = self.getlabel() if isinstance(label, basestring): label = None, label - self.button.create(*label) + if label is None: + self.button.remove() + else: + self.button.create(*label) + self.timer = Timer(self.interval, self.tick) + self.timer.daemon = True self.timer.start() def getlabel(self): if self.action: - return self.action() - return () + return self.action(self) + return None _active = True def _set_active(self, val): self._active = bool(val) - if val: - self.tick() - else: + self.tick() + if not val: self.button.remove() active = property( diff --git a/alternative_wmiircs/python/wmiirc b/alternative_wmiircs/python/wmiirc @@ -39,10 +39,10 @@ terminal = 'wmiir', 'setsid', 'xterm' pygmi.shell = os.environ.get('SHELL', 'sh') @defmonitor -def load(): +def load(self): return re.sub(r'^.*: ', '', call('uptime')).replace(', ', ' ') @defmonitor -def time(): +def time(self): from datetime import datetime return datetime.now().strftime('%c') @@ -75,8 +75,8 @@ bind_events({ 'DestroyTag': tags.delete, 'FocusTag': tags.focus, 'UnfocusTag': tags.unfocus, - 'UrgentTag': lambda args: tags.set_urgent(args.split(' ')[1], True), - 'NotUrgentTag': lambda args: tags.set_urgent(args.split(' ')[1], False), + 'UrgentTag': lambda args: tags.set_urgent(args.split()[1], True), + 'NotUrgentTag': lambda args: tags.set_urgent(args.split()[1], False), 'AreaFocus': lambda args: (args == '~' and (setbackground(floatbackground), True) or @@ -88,10 +88,10 @@ bind_events({ 'Notice': lambda args: notice.show(args), ('LeftBarClick', 'LeftBarDND'): - lambda args: args.split(' ')[0] == '1' and tags.select(args.split(' ', 1)[1]), + lambda args: args.split()[0] == '1' and tags.select(args.split(' ', 1)[1]), - 'ClientMouseDown': lambda args: menu(*args.split(' '), type='client'), - 'LeftBarMouseDown': lambda args: menu(*reversed(args.split(' ')), type='lbar'), + 'ClientMouseDown': lambda args: menu(*args.split(), type='client'), + 'LeftBarMouseDown': lambda args: menu(*reversed(args.split()), type='lbar'), }) @apply @@ -139,9 +139,12 @@ class Notice(Button): def tick(self): self.label = '' + def write(self, notice): + client.write('/event', 'Notice %s' % notice.replace('\n', ' ')) + def show(self, notice): if self.timer: - self.timer.stop() + self.timer.cancel() self.label = notice from threading import Timer self.timer = Timer(noticetimeout, self.tick) diff --git a/cmd/wmii.rc.rc b/cmd/wmii.rc.rc @@ -133,6 +133,10 @@ fn wi_seltag { wmiir read /tag/sel/ctl | sed 1q } +fn wi_selclient { + wmiir read /client/sel/ctl | sed 1q +} + fn wi_readevent { wmiir read /event } diff --git a/cmd/wmii.sh.sh b/cmd/wmii.sh.sh @@ -169,6 +169,10 @@ wi_seltag() { wmiir read /tag/sel/ctl | sed 1q | tr -d '\012' } +wi_selclient() { + wmiir read /client/sel/ctl | sed 1q | tr -d '\012' +} + wi_eventloop() { echo "$Keys" | wmiir write /keys diff --git a/rc/rc.wmii.rc b/rc/rc.wmii.rc @@ -229,7 +229,7 @@ key $MODKEY-Return || fn $key { key $MODKEY-t || fn $key { wmiir xwrite /ctl view `{wi_tags | wimenu -h $hist.tag -n 50} &} key $MODKEY-Shift-t || fn $key { - sel = `{wmiir read /client/sel/ctl | sed 1q} \ + sel = `{wi_selclient} \ wmiir xwrite /client/$sel/tags `{wi_tags | wimenu -h $hist.tag -n 50} &} key $MODKEY-^`{seq 0 9} || fn $key { diff --git a/rc/wmiirc.sh b/rc/wmiirc.sh @@ -163,7 +163,7 @@ events() { Key $MODKEY-Shift-c wmiir xwrite /client/sel/ctl kill Key $MODKEY-Shift-t - wmiir xwrite "/client/$(wmiir read /client/sel/ctl)/tags" $(wi_tags | wimenu -h "${hist}.tags" -n 50) & + wmiir xwrite "/client/$(wi_selclient)/tags" $(wi_tags | wimenu -h "${hist}.tags" -n 50) & Key $MODKEY-$LEFT wmiir xwrite /tag/sel/ctl select left Key $MODKEY-$RIGHT