From 24ab1ce475bc17f28a7a1d3fd6666d82757e290c Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 4 Mar 2014 01:44:33 +0100 Subject: beginning of xmonad plugin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/__main__.py | 5 +++-- src/util.py | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/__main__.py b/src/__main__.py index 1196341..6077a98 100755 --- a/src/__main__.py +++ b/src/__main__.py @@ -228,7 +228,7 @@ class Bar: buf = [int('0' + x) for x in buf] bci, fci = 0, 0 for b in buf: - if bci != 0: + if not bci == 0: if bci == 1: if not b == 2: bci = -2 @@ -237,9 +237,10 @@ class Bar: bc = (bc << 8) + b if bci == 4: bci = -1 + bc = (bc >> 16) & 255, (bc >> 8) & 255, bc & 255 bc = self.create_colour(*bc) bci += 1 - elif fci != 0: + elif not fci == 0: if fci == 1: if not b == 2: fci = -2 diff --git a/src/util.py b/src/util.py index 4d229ef..9c8c9d5 100644 --- a/src/util.py +++ b/src/util.py @@ -42,13 +42,25 @@ def watch(interval, target, delay = 0): @param interval:float The number of seconds to sleep between invocatons @param target:()→void The function - @param delay:float Number of extra seconds seconds to wait the first time + @param delay:float Number of extra seconds to wait the first time ''' - target() if not delay == 0: time.sleep(delay) while True: + target() time.sleep(interval) + + +def forever(target, delay = 0): + ''' + Run a function continuously forever + + @param target:()→void The function + @param delay:float Number of extra seconds to wait the first time + ''' + if not delay == 0: + time.sleep(delay) + while True: target() -- cgit v1.2.3-70-g09d2