2018-05-17 01:45:08 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import sys
|
|
|
|
from datetime import datetime
|
|
|
|
import time
|
|
|
|
import pytz
|
|
|
|
|
|
|
|
|
2019-03-01 17:58:32 +01:00
|
|
|
FILL_CLOCK_FACE = False
|
|
|
|
|
|
|
|
|
2018-05-17 01:45:08 +02:00
|
|
|
try:
|
2018-08-06 20:20:20 +02:00
|
|
|
# if len(sys.argv) < 3:
|
|
|
|
# print("Usage: {scriptname} timezone_left timezone_right".format(scriptname=sys.argv[0]), file=sys.stderr)
|
|
|
|
# exit(1)
|
2018-05-17 17:01:38 +02:00
|
|
|
|
2018-08-06 20:20:20 +02:00
|
|
|
# try:
|
|
|
|
# tzleft = pytz.timezone(sys.argv[1])
|
|
|
|
# tzright = pytz.timezone(sys.argv[2])
|
|
|
|
# except pytz.exceptions.UnknownTimeZoneError as e:
|
|
|
|
# print('Unknown time zone "{}"'.format(e.args[0]), file=sys.stderr)
|
|
|
|
# exit(1)
|
2018-05-17 17:01:38 +02:00
|
|
|
|
2018-05-17 01:45:08 +02:00
|
|
|
|
2018-05-20 23:37:43 +02:00
|
|
|
hourhands = ""
|
|
|
|
minutehands = ""
|
2018-05-17 01:45:08 +02:00
|
|
|
|
2018-05-17 17:01:38 +02:00
|
|
|
def face_for(t):
|
2018-05-20 23:37:43 +02:00
|
|
|
minute = minutehands[ t.minute // 5 ]
|
|
|
|
hour = hourhands [ t.hour % 12 ]
|
2018-05-17 01:45:08 +02:00
|
|
|
|
2019-03-01 17:58:32 +01:00
|
|
|
if FILL_CLOCK_FACE:
|
2022-08-29 23:44:02 +02:00
|
|
|
return "%{O1}%{T8}" + color_for(t) + "%{F#000}" + hour + minute + "" + "%{T-}%{F}"
|
2019-03-01 17:58:32 +01:00
|
|
|
else:
|
2022-08-29 23:44:02 +02:00
|
|
|
return "%{O1}%{T8}" + color_for(t) + hour + minute + "%{T-}%{F}"
|
2018-05-17 01:45:08 +02:00
|
|
|
|
|
|
|
|
2018-05-17 17:01:38 +02:00
|
|
|
def color_for(t):
|
|
|
|
if t.hour < 5 or t.hour > 22:
|
2022-09-05 00:20:25 +02:00
|
|
|
return "%{F#888888}" # "%{F#888}"
|
2018-05-17 17:01:38 +02:00
|
|
|
elif t.hour < 10:
|
2022-09-05 00:20:25 +02:00
|
|
|
return "%{F#e2d39a}" # "%{F#DB9}"
|
2018-05-17 17:01:38 +02:00
|
|
|
elif t.hour < 14:
|
2022-09-05 00:20:25 +02:00
|
|
|
return "%{F#dec7aa}" # "%{F#DDB}"
|
2018-05-17 17:01:38 +02:00
|
|
|
elif t.hour < 19:
|
2022-09-05 00:20:25 +02:00
|
|
|
return "%{F#deceb0}" # "%{F#DDD}"
|
2018-05-17 17:01:38 +02:00
|
|
|
else:
|
2022-09-05 00:20:25 +02:00
|
|
|
return "%{F#ff948d}" # "%{F#D9B}"
|
2018-05-17 01:45:08 +02:00
|
|
|
|
|
|
|
|
2018-05-17 17:01:38 +02:00
|
|
|
while True:
|
|
|
|
utcnow = datetime.now(tz=pytz.utc)
|
|
|
|
localnow = datetime.now()
|
2018-08-06 20:20:20 +02:00
|
|
|
# leftnow = utcnow.astimezone(tzleft )
|
|
|
|
# rightnow = utcnow.astimezone(tzright)
|
2018-05-20 23:44:30 +02:00
|
|
|
|
|
|
|
localcolor = color_for(localnow)
|
|
|
|
|
2018-08-22 01:55:05 +02:00
|
|
|
khal_link = lambda x: "%{A1:i3-sensible-terminal -x khal interactive &:}" + x + "%{A}"
|
|
|
|
clock_link = lambda x, args: "%{A1:i3-sensible-terminal -x tty-clock -cC3 " + args + " &:}" + x + "%{A}"
|
2018-08-20 03:07:18 +02:00
|
|
|
|
2018-05-17 17:01:38 +02:00
|
|
|
print(
|
2018-08-20 03:07:18 +02:00
|
|
|
khal_link(
|
|
|
|
localcolor +
|
|
|
|
localnow.strftime("%A") +
|
|
|
|
"%{F} "
|
|
|
|
) +
|
2018-05-20 23:37:43 +02:00
|
|
|
|
2018-08-06 20:20:20 +02:00
|
|
|
# face_for(leftnow) +
|
2018-05-17 01:45:08 +02:00
|
|
|
|
2018-08-20 03:07:18 +02:00
|
|
|
clock_link(" %{T4}" + localcolor + localnow.strftime("%H") + "%{F}", "") +
|
2018-08-20 03:22:11 +02:00
|
|
|
clock_link("%{O2}%{T8}" + face_for(localnow), "-D") +
|
2018-08-20 03:07:18 +02:00
|
|
|
clock_link("%{O2}%{T4}" + localcolor + localnow.strftime("%M") + "%{T-}%{F} ", "-s") +
|
2018-05-17 01:45:08 +02:00
|
|
|
|
2018-08-06 20:20:20 +02:00
|
|
|
# face_for(rightnow) + " " +
|
2018-05-20 23:37:43 +02:00
|
|
|
|
2018-08-20 03:07:18 +02:00
|
|
|
khal_link(
|
|
|
|
" " +
|
|
|
|
localcolor +
|
|
|
|
localnow.strftime("%d %b") +
|
|
|
|
"%{F}"
|
|
|
|
),
|
2018-05-17 01:45:08 +02:00
|
|
|
|
2018-05-17 17:01:38 +02:00
|
|
|
flush = True
|
|
|
|
)
|
2018-05-17 01:45:08 +02:00
|
|
|
|
2018-05-17 17:01:38 +02:00
|
|
|
delay = 60 - localnow.second - (localnow.microsecond * 10e-7)
|
|
|
|
time.sleep(delay)
|
2018-05-17 01:45:08 +02:00
|
|
|
|
2018-05-17 17:01:38 +02:00
|
|
|
except Exception as e:
|
|
|
|
print(e, file=sys.stderr)
|