aboutsummaryrefslogtreecommitdiffstats
path: root/examples/clock
blob: c7d9ac29f7742099f5a6c6ef53a389cce8e7f147 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- python -*-

# A simple xpybar configuration example of a clock

import time
import threading

from plugins.clock import Clock


OUTPUT, HEIGHT, YPOS, TOP = 0, 12, 24, True


clock = Clock(format = '%Y-(%m)%b-%d %T, %a w%V, %Z', utc = False, sync_to = Clock.SECONDS)


start_ = start
def start():
    start_()
    def refresh():
        if redraw():
            get_display().flush()
    async(lambda : clock.continuous_sync(refresh))


semaphore = threading.Semaphore()
def redraw():
    if semaphore.acquire(blocking = False):
        text = clock.read()
        bar.clear()
        bar.draw_coloured_text(0, 10, 0, 2, text)
        semaphore.release()
        return True
    return False