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/mysun.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 '')
-rw-r--r-- | xpybar/config/mysun.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/xpybar/config/mysun.py b/xpybar/config/mysun.py new file mode 100644 index 0000000..cfd1d5c --- /dev/null +++ b/xpybar/config/mysun.py @@ -0,0 +1,43 @@ +# -*- python -*- +from common import * + +class MySun(Entry): + def __init__(self, *args, clock = None, **kwargs): + self.text = '...' + self.clock = clock + Entry.__init__(self, *args, **kwargs) + xasync(self.wait, name = 'solar') + + def wait(self): + palette = None + while palette is None: + try: + palette = G.bar.palette + except: + time.sleep(0.1) + twilight_12 = colour_interpol(palette[1], palette[3], 1 / 3) + twilight_6 = colour_interpol(palette[1], palette[3], 2 / 3) + command = pdeath('HUP', 'blueshift', '-c', HOME + '/.config/xpybar/bin/sun') + while True: + try: + text = 'Sun: %s' % spawn_read(*command) + if self.clock is not None: + elevation = float(text.split(' ')[3][:-1]) + if elevation <= -18: self.clock.twilight = '31' + elif elevation <= -12: self.clock.twilight = twilight_12 + elif elevation <= -6: self.clock.twilight = twilight_6 + elif elevation <= 0: self.clock.twilight = '33' + elif elevation <= 6: self.clock.twilight = '39' + else: self.clock.twilight = '34' + self.clock.invalidate() + except: + text = '¿Cannot get solar information?' + if self.clock is not None: + self.clock.twilight = '39' + self.clock.invalidate() + self.text = text + self.invalidate() + time.sleep(20) + + def function(self): + return self.text |