aboutsummaryrefslogtreecommitdiffstats
path: root/src/util.py
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-03-04 01:44:33 +0100
committerMattias Andrée <maandree@operamail.com>2014-03-04 01:44:33 +0100
commit24ab1ce475bc17f28a7a1d3fd6666d82757e290c (patch)
treea92b061b2136fbc7bb00135a3ca8784568e221d5 /src/util.py
parentreduce filker (diff)
downloadxpybar-24ab1ce475bc17f28a7a1d3fd6666d82757e290c.tar.gz
xpybar-24ab1ce475bc17f28a7a1d3fd6666d82757e290c.tar.bz2
xpybar-24ab1ce475bc17f28a7a1d3fd6666d82757e290c.tar.xz
beginning of xmonad plugin
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/util.py')
-rw-r--r--src/util.py16
1 files changed, 14 insertions, 2 deletions
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()