diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-03-02 15:29:24 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-03-02 15:30:11 +0100 |
commit | 6cadf2da966da7ad5f7b613e14b0cb30239f0b82 (patch) | |
tree | bda35326dfcbc4847d78e696e1f33450664971ab /examples/clock | |
parent | add xdisplay (diff) | |
download | xpybar-6cadf2da966da7ad5f7b613e14b0cb30239f0b82.tar.gz xpybar-6cadf2da966da7ad5f7b613e14b0cb30239f0b82.tar.bz2 xpybar-6cadf2da966da7ad5f7b613e14b0cb30239f0b82.tar.xz |
m + fix threading weirdness + add clock example
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | examples/clock | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/examples/clock b/examples/clock new file mode 100644 index 0000000..4984213 --- /dev/null +++ b/examples/clock @@ -0,0 +1,33 @@ +# -*- python -*- + +# A simple xpybar configuration example of a clock + +import time +import threading + + +OUTPUT, HEIGHT, YPOS, TOP = 0, 12, 24, True + + +start_ = start +def start(): + start_() + def clock(): + while True: + time.sleep(0.1) + time.sleep(1 - (time.time() % 1)) + if redraw(): + get_display().flush() + async(clock) + + +semaphore = threading.Semaphore() +def redraw(): + if semaphore.acquire(blocking = False): + text = spawn_read('date', '+%Y-(%m)%b-%d %T, %a w%V, %Z') + bar.clear() + bar.draw_coloured_text(0, 10, 0, 2, text) + semaphore.release() + return True + return False + |