Fix Mod-Shift-t in wmiirc.

This commit is contained in:
Kris Maglione 2009-05-19 13:14:06 -04:00
parent 120f5a34a3
commit 3dd6ee6658
7 changed files with 37 additions and 22 deletions

View File

@ -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 *

View File

@ -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(

View File

@ -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)

View File

@ -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
}

View File

@ -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

View File

@ -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 {

View File

@ -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