mirror of
https://github.com/0intro/wmii
synced 2024-11-22 05:42:05 +03:00
Make a better attempt to keep up with color scheme changes in python wmiirc without extra roundtrips.
This commit is contained in:
parent
e156d03e09
commit
4b51770266
@ -36,7 +36,7 @@ class Ctl(object):
|
||||
ctl_hasid = False
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
self.cache = {}
|
||||
|
||||
def ctl(self, *args):
|
||||
"""
|
||||
@ -56,6 +56,7 @@ class Ctl(object):
|
||||
return key in self.keys()
|
||||
def __setitem__(self, key, val):
|
||||
assert '\n' not in key
|
||||
self.cache[key] = val
|
||||
if key in self.ctl_types:
|
||||
val = self.ctl_types[key][1](val)
|
||||
self.ctl(key, val)
|
||||
@ -610,8 +611,8 @@ class Tags(object):
|
||||
self.ignore = set()
|
||||
self.tags = {}
|
||||
self.sel = None
|
||||
self.normcol = normcol or wmii['normcolors']
|
||||
self.focuscol = focuscol or wmii['focuscolors']
|
||||
self.normcol = normcol
|
||||
self.focuscol = focuscol
|
||||
self.lastselect = datetime.now()
|
||||
for t in wmii.tags:
|
||||
self.add(t.id)
|
||||
@ -626,15 +627,15 @@ class Tags(object):
|
||||
|
||||
def add(self, tag):
|
||||
self.tags[tag] = Tag(tag)
|
||||
self.tags[tag].button = Button('left', tag, self.normcol, tag)
|
||||
self.tags[tag].button = Button('left', tag, self.normcol or wmii.cache['normcolors'], tag)
|
||||
def delete(self, tag):
|
||||
self.tags.pop(tag).button.remove()
|
||||
|
||||
def focus(self, tag):
|
||||
self.sel = self.tags[tag]
|
||||
self.sel.button.colors = self.focuscol
|
||||
self.sel.button.colors = self.focuscol or wmii.cache['focuscolors']
|
||||
def unfocus(self, tag):
|
||||
self.tags[tag].button.colors = self.normcol
|
||||
self.tags[tag].button.colors = self.normcol or wmii.cache['normcolors']
|
||||
|
||||
def set_urgent(self, tag, urgent=True):
|
||||
self.tags[tag].button.label = urgent and '*' + tag or tag
|
||||
|
@ -57,7 +57,7 @@ class Monitor(object):
|
||||
Initializes the new monitor. For parameter values, see the
|
||||
corresponding property values in the class's docstring.
|
||||
|
||||
Param color: The initial colors for the monitor.
|
||||
Param colors: The initial colors for the monitor.
|
||||
Param label: The initial label for the monitor.
|
||||
"""
|
||||
if side:
|
||||
|
@ -4,7 +4,7 @@ import os
|
||||
import re
|
||||
import sys
|
||||
import traceback
|
||||
from threading import Thread
|
||||
from threading import Thread, Timer
|
||||
|
||||
import pygmi
|
||||
from pygmi import *
|
||||
@ -50,10 +50,10 @@ pygmi.shell = os.environ.get('SHELL', 'sh')
|
||||
|
||||
@defmonitor
|
||||
def load(self):
|
||||
return re.sub(r'^.*: ', '', call('uptime')).replace(', ', ' ')
|
||||
return wmii.cache['normcolors'], re.sub(r'^.*: ', '', call('uptime')).replace(', ', ' ')
|
||||
@defmonitor
|
||||
def time(self):
|
||||
return datetime.datetime.now().strftime('%c')
|
||||
return wmii.cache['focuscolors'], datetime.datetime.now().strftime('%c')
|
||||
|
||||
wmii.colrules = (
|
||||
('gimp', '17+83+41'),
|
||||
@ -143,11 +143,12 @@ def clickmenu(choices, args):
|
||||
|
||||
class Notice(Button):
|
||||
def __init__(self):
|
||||
super(Notice, self).__init__(*noticebar, colors=wmii['normcolors'])
|
||||
super(Notice, self).__init__(*noticebar, colors=wmii.cache['normcolors'])
|
||||
self.timer = None
|
||||
self.show(' ')
|
||||
|
||||
def tick(self):
|
||||
self.label = ' '
|
||||
self.create(wmii.cache['normcolors'], ' ')
|
||||
|
||||
def write(self, notice):
|
||||
client.awrite('/event', 'Notice %s' % notice.replace('\n', ' '))
|
||||
@ -155,8 +156,7 @@ class Notice(Button):
|
||||
def show(self, notice):
|
||||
if self.timer:
|
||||
self.timer.cancel()
|
||||
self.label = notice
|
||||
from threading import Timer
|
||||
self.create(wmii.cache['normcolors'], notice)
|
||||
self.timer = Timer(noticetimeout, self.tick)
|
||||
self.timer.start()
|
||||
notice = Notice()
|
||||
@ -294,6 +294,7 @@ addresize('Shift-', 'Nudge', 'nudge')
|
||||
|
||||
Actions.rehash()
|
||||
|
||||
if not os.environ.get('WMII_NOPLUGINS', ''):
|
||||
dirs = filter(curry(os.access, _, os.R_OK),
|
||||
('%s/plugins' % dir for dir in confpath))
|
||||
files = filter(re.compile(r'\.py$').match,
|
||||
|
Loading…
Reference in New Issue
Block a user