diff options
author | Mattias Andrée <maandree@kth.se> | 2021-06-26 13:18:37 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-06-26 13:18:37 +0200 |
commit | 3e21f6d13c0a70db95fec8b5a71b758223ff4293 (patch) | |
tree | 6d6d2eddb243935007ce1e316c61470224f93df0 /xpybar/config/myirc.py | |
parent | Add inputrc for readline + m (diff) | |
download | dotfiles-3e21f6d13c0a70db95fec8b5a71b758223ff4293.tar.gz dotfiles-3e21f6d13c0a70db95fec8b5a71b758223ff4293.tar.bz2 dotfiles-3e21f6d13c0a70db95fec8b5a71b758223ff4293.tar.xz |
Add xpybar
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'xpybar/config/myirc.py')
-rw-r--r-- | xpybar/config/myirc.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/xpybar/config/myirc.py b/xpybar/config/myirc.py new file mode 100644 index 0000000..3fa4b71 --- /dev/null +++ b/xpybar/config/myirc.py @@ -0,0 +1,38 @@ +# -*- python -*- +from common import * + +class MyIRC(Entry): + def __init__(self, *args, ii = None, **kwargs): + self.semaphore = threading.Semaphore() + self.text = 'Irc: 0' + self.count = 0 + self.ii = ii + Entry.__init__(self, *args, **kwargs) + + def colourise(self, n): + if n >= 1: return '32' + if n >= 5: return '33' + if n >= 10: return '31' + return '39' + + def adjust(self, n): + self.semaphore.acquire() + try: + self.count += n + if self.count < 0: + self.count = 0 + self.text = 'Irc: \033[%sm%i\033[0m' % (self.colourise(self.count), self.count) + finally: + self.semaphore.release() + self.invalidate() + + def action(self, col, button, x, y): + if self.count == 0: + return + if button == LEFT_BUTTON: + G.groupi = 1 + G.group = G.groups[G.groupi] + self.ii.action(0, RIGHT_BUTTON, 0, 0) + + def function(self): + return self.text |