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
|
ctl_hasid = False
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
self.cache = {}
|
||||||
|
|
||||||
def ctl(self, *args):
|
def ctl(self, *args):
|
||||||
"""
|
"""
|
||||||
@ -56,6 +56,7 @@ class Ctl(object):
|
|||||||
return key in self.keys()
|
return key in self.keys()
|
||||||
def __setitem__(self, key, val):
|
def __setitem__(self, key, val):
|
||||||
assert '\n' not in key
|
assert '\n' not in key
|
||||||
|
self.cache[key] = val
|
||||||
if key in self.ctl_types:
|
if key in self.ctl_types:
|
||||||
val = self.ctl_types[key][1](val)
|
val = self.ctl_types[key][1](val)
|
||||||
self.ctl(key, val)
|
self.ctl(key, val)
|
||||||
@ -610,8 +611,8 @@ class Tags(object):
|
|||||||
self.ignore = set()
|
self.ignore = set()
|
||||||
self.tags = {}
|
self.tags = {}
|
||||||
self.sel = None
|
self.sel = None
|
||||||
self.normcol = normcol or wmii['normcolors']
|
self.normcol = normcol
|
||||||
self.focuscol = focuscol or wmii['focuscolors']
|
self.focuscol = focuscol
|
||||||
self.lastselect = datetime.now()
|
self.lastselect = datetime.now()
|
||||||
for t in wmii.tags:
|
for t in wmii.tags:
|
||||||
self.add(t.id)
|
self.add(t.id)
|
||||||
@ -626,15 +627,15 @@ class Tags(object):
|
|||||||
|
|
||||||
def add(self, tag):
|
def add(self, tag):
|
||||||
self.tags[tag] = Tag(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):
|
def delete(self, tag):
|
||||||
self.tags.pop(tag).button.remove()
|
self.tags.pop(tag).button.remove()
|
||||||
|
|
||||||
def focus(self, tag):
|
def focus(self, tag):
|
||||||
self.sel = self.tags[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):
|
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):
|
def set_urgent(self, tag, urgent=True):
|
||||||
self.tags[tag].button.label = urgent and '*' + tag or tag
|
self.tags[tag].button.label = urgent and '*' + tag or tag
|
||||||
|
@ -57,8 +57,8 @@ class Monitor(object):
|
|||||||
Initializes the new monitor. For parameter values, see the
|
Initializes the new monitor. For parameter values, see the
|
||||||
corresponding property values in the class's docstring.
|
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.
|
Param label: The initial label for the monitor.
|
||||||
"""
|
"""
|
||||||
if side:
|
if side:
|
||||||
self.side = side
|
self.side = side
|
||||||
|
@ -4,7 +4,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
from threading import Thread
|
from threading import Thread, Timer
|
||||||
|
|
||||||
import pygmi
|
import pygmi
|
||||||
from pygmi import *
|
from pygmi import *
|
||||||
@ -50,10 +50,10 @@ pygmi.shell = os.environ.get('SHELL', 'sh')
|
|||||||
|
|
||||||
@defmonitor
|
@defmonitor
|
||||||
def load(self):
|
def load(self):
|
||||||
return re.sub(r'^.*: ', '', call('uptime')).replace(', ', ' ')
|
return wmii.cache['normcolors'], re.sub(r'^.*: ', '', call('uptime')).replace(', ', ' ')
|
||||||
@defmonitor
|
@defmonitor
|
||||||
def time(self):
|
def time(self):
|
||||||
return datetime.datetime.now().strftime('%c')
|
return wmii.cache['focuscolors'], datetime.datetime.now().strftime('%c')
|
||||||
|
|
||||||
wmii.colrules = (
|
wmii.colrules = (
|
||||||
('gimp', '17+83+41'),
|
('gimp', '17+83+41'),
|
||||||
@ -143,11 +143,12 @@ def clickmenu(choices, args):
|
|||||||
|
|
||||||
class Notice(Button):
|
class Notice(Button):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(Notice, self).__init__(*noticebar, colors=wmii['normcolors'])
|
super(Notice, self).__init__(*noticebar, colors=wmii.cache['normcolors'])
|
||||||
self.timer = None
|
self.timer = None
|
||||||
|
self.show(' ')
|
||||||
|
|
||||||
def tick(self):
|
def tick(self):
|
||||||
self.label = ' '
|
self.create(wmii.cache['normcolors'], ' ')
|
||||||
|
|
||||||
def write(self, notice):
|
def write(self, notice):
|
||||||
client.awrite('/event', 'Notice %s' % notice.replace('\n', ' '))
|
client.awrite('/event', 'Notice %s' % notice.replace('\n', ' '))
|
||||||
@ -155,8 +156,7 @@ class Notice(Button):
|
|||||||
def show(self, notice):
|
def show(self, notice):
|
||||||
if self.timer:
|
if self.timer:
|
||||||
self.timer.cancel()
|
self.timer.cancel()
|
||||||
self.label = notice
|
self.create(wmii.cache['normcolors'], notice)
|
||||||
from threading import Timer
|
|
||||||
self.timer = Timer(noticetimeout, self.tick)
|
self.timer = Timer(noticetimeout, self.tick)
|
||||||
self.timer.start()
|
self.timer.start()
|
||||||
notice = Notice()
|
notice = Notice()
|
||||||
@ -294,14 +294,15 @@ addresize('Shift-', 'Nudge', 'nudge')
|
|||||||
|
|
||||||
Actions.rehash()
|
Actions.rehash()
|
||||||
|
|
||||||
dirs = filter(curry(os.access, _, os.R_OK),
|
if not os.environ.get('WMII_NOPLUGINS', ''):
|
||||||
('%s/plugins' % dir for dir in confpath))
|
dirs = filter(curry(os.access, _, os.R_OK),
|
||||||
files = filter(re.compile(r'\.py$').match,
|
('%s/plugins' % dir for dir in confpath))
|
||||||
reduce(operator.add, map(os.listdir, dirs), []))
|
files = filter(re.compile(r'\.py$').match,
|
||||||
for f in ['wmiirc_local'] + ['plugins.%s' % file[:-3] for file in files]:
|
reduce(operator.add, map(os.listdir, dirs), []))
|
||||||
try:
|
for f in ['wmiirc_local'] + ['plugins.%s' % file[:-3] for file in files]:
|
||||||
exec 'import %s' % f
|
try:
|
||||||
except Exception, e:
|
exec 'import %s' % f
|
||||||
traceback.print_exc(sys.stdout)
|
except Exception, e:
|
||||||
|
traceback.print_exc(sys.stdout)
|
||||||
|
|
||||||
# vim:se sts=4 sw=4 et:
|
# vim:se sts=4 sw=4 et:
|
||||||
|
Loading…
Reference in New Issue
Block a user