aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-03-03 14:08:00 +0100
committerMattias Andrée <maandree@operamail.com>2014-03-03 14:08:00 +0100
commit01d5043106dbc8d5b0a63024d0c2a81b1ee63bb9 (patch)
tree82781d2f22baafb5d50694efcc01e449d39ec66c /examples
parentadd todo to xdisplay about vt (diff)
downloadxpybar-01d5043106dbc8d5b0a63024d0c2a81b1ee63bb9.tar.gz
xpybar-01d5043106dbc8d5b0a63024d0c2a81b1ee63bb9.tar.bz2
xpybar-01d5043106dbc8d5b0a63024d0c2a81b1ee63bb9.tar.xz
add clock
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--examples/clock18
-rw-r--r--examples/plugin-test6
2 files changed, 15 insertions, 9 deletions
diff --git a/examples/clock b/examples/clock
index 4984213..c7d9ac2 100644
--- a/examples/clock
+++ b/examples/clock
@@ -5,26 +5,28 @@
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 clock():
- while True:
- time.sleep(0.1)
- time.sleep(1 - (time.time() % 1))
- if redraw():
- get_display().flush()
- async(clock)
+ def refresh():
+ if redraw():
+ get_display().flush()
+ async(lambda : clock.continuous_sync(refresh))
semaphore = threading.Semaphore()
def redraw():
if semaphore.acquire(blocking = False):
- text = spawn_read('date', '+%Y-(%m)%b-%d %T, %a w%V, %Z')
+ text = clock.read()
bar.clear()
bar.draw_coloured_text(0, 10, 0, 2, text)
semaphore.release()
diff --git a/examples/plugin-test b/examples/plugin-test
index 619b6f5..9cf449c 100644
--- a/examples/plugin-test
+++ b/examples/plugin-test
@@ -16,13 +16,17 @@ from plugins.discstats import DiscStats
from plugins.xdisplay import XDisplay
from plugins.moc import MOC
from plugins.cpu import CPU
+from plugins.clock import Clock
OUTPUT, HEIGHT, YPOS, TOP = 0, 24, 24, True
+clock = Clock(format = '%Y-(%m)%b-%d %T, %a w%V, %Z')
+
+
def redraw():
- date = spawn_read('date', '+%Y-(%m)%b-%d %T, %a w%V, %Z')
+ date = clock.read()
uptime_ = Uptime()
uptime = '%id %02i:%02i:%05.2f' % uptime_.uptime