[hackers] [wmii] Fix Mod-Shift-t in wmiirc. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Tue, 19 May 2009 17:14:11 +0000 (UTC)

changeset: 2457:1c29e1952494
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Tue May 19 13:14:06 2009 -0400
files: alternative_wmiircs/python/pygmi/__init__.py alternative_wmiircs/python/pygmi/monitor.py alternative_wmiircs/python/wmiirc cmd/wmii.rc.rc cmd/wmii.sh.sh rc/rc.wmii.rc rc/wmiirc.sh
description:
Fix Mod-Shift-t in wmiirc.

diff -r d1a33e9207d0 -r 1c29e1952494 alternative_wmiircs/python/pygmi/__init__.py
--- a/alternative_wmiircs/python/pygmi/__init__.py Sun May 17 21:23:57 2009 -0400
+++ b/alternative_wmiircs/python/pygmi/__init__.py Tue May 19 13:14:06 2009 -0400
@@ -1,4 +1,5 @@
 import os
+import sys
 
 from pyxp import Client
 
@@ -40,8 +41,10 @@
         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 -r d1a33e9207d0 -r 1c29e1952494 alternative_wmiircs/python/pygmi/monitor.py
--- a/alternative_wmiircs/python/pygmi/monitor.py Sun May 17 21:23:57 2009 -0400
+++ b/alternative_wmiircs/python/pygmi/monitor.py Tue May 19 13:14:06 2009 -0400
@@ -53,32 +53,33 @@
         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 -r d1a33e9207d0 -r 1c29e1952494 alternative_wmiircs/python/wmiirc
--- a/alternative_wmiircs/python/wmiirc Sun May 17 21:23:57 2009 -0400
+++ b/alternative_wmiircs/python/wmiirc Tue May 19 13:14:06 2009 -0400
@@ -39,10 +39,10 @@
 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 @@
     '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 @@
     '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 @@
     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 -r d1a33e9207d0 -r 1c29e1952494 cmd/wmii.rc.rc
--- a/cmd/wmii.rc.rc Sun May 17 21:23:57 2009 -0400
+++ b/cmd/wmii.rc.rc Tue May 19 13:14:06 2009 -0400
@@ -133,6 +133,10 @@
         wmiir read /tag/sel/ctl | sed 1q
 }
 
+fn wi_selclient {
+ wmiir read /client/sel/ctl | sed 1q
+}
+
 fn wi_readevent {
         wmiir read /event
 }
diff -r d1a33e9207d0 -r 1c29e1952494 cmd/wmii.sh.sh
--- a/cmd/wmii.sh.sh Sun May 17 21:23:57 2009 -0400
+++ b/cmd/wmii.sh.sh Tue May 19 13:14:06 2009 -0400
@@ -169,6 +169,10 @@
         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 -r d1a33e9207d0 -r 1c29e1952494 rc/rc.wmii.rc
--- a/rc/rc.wmii.rc Sun May 17 21:23:57 2009 -0400
+++ b/rc/rc.wmii.rc Tue May 19 13:14:06 2009 -0400
@@ -229,7 +229,7 @@
 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 -r d1a33e9207d0 -r 1c29e1952494 rc/wmiirc.sh
--- a/rc/wmiirc.sh Sun May 17 21:23:57 2009 -0400
+++ b/rc/wmiirc.sh Tue May 19 13:14:06 2009 -0400
@@ -163,7 +163,7 @@
         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
Received on Tue May 19 2009 - 17:14:11 UTC

This archive was generated by hypermail 2.2.0 : Tue May 19 2009 - 17:24:05 UTC