From 6cadf2da966da7ad5f7b613e14b0cb30239f0b82 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 2 Mar 2014 15:29:24 +0100 Subject: m + fix threading weirdness + add clock example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- examples/clock | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 examples/clock (limited to 'examples/clock') 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 + -- cgit v1.2.3-70-g09d2