new and improved
This commit is contained in:
@@ -22,7 +22,7 @@ ascii_digits = {
|
|||||||
":": " . . ",
|
":": " . . ",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# fmt: off
|
||||||
fancy_digits = {
|
fancy_digits = {
|
||||||
"0": ("▗▄▖"
|
"0": ("▗▄▖"
|
||||||
"█ █"
|
"█ █"
|
||||||
@@ -78,7 +78,7 @@ fancy_digits = {
|
|||||||
"▝▀▘"),
|
"▝▀▘"),
|
||||||
":": " ▗ ▝ ",
|
":": " ▗ ▝ ",
|
||||||
}
|
}
|
||||||
|
# fmt: on
|
||||||
# ~ ░ ▒ ▓
|
# ~ ░ ▒ ▓
|
||||||
|
|
||||||
|
|
||||||
@@ -158,16 +158,17 @@ def drawdigital(win, y, x, t, ascii=False):
|
|||||||
drawdigit(win, y, x + 4 * c, hrs[c], ascii=ascii)
|
drawdigit(win, y, x + 4 * c, hrs[c], ascii=ascii)
|
||||||
|
|
||||||
|
|
||||||
def drawalarms(stdscr, y, x, t, alarms):
|
def drawalarms(stdscr, y, x, t, alarms, tick_tock):
|
||||||
ya = y
|
ya = y
|
||||||
now = 100 * t.tm_hour + t.tm_min
|
now = 100 * t.tm_hour + t.tm_min
|
||||||
is_alarm = False
|
is_alarm = False
|
||||||
for alarm in alarms:
|
for alarm in alarms:
|
||||||
if alarm["hstart"] <= now and alarm["hend"] >= now:
|
if alarm["hstart"] <= now and alarm["hend"] >= now:
|
||||||
if t.tm_sec % 2 == 0:
|
color = (
|
||||||
color = curses.color_pair(4) + curses.A_BOLD + curses.A_REVERSE
|
curses.color_pair(4) + curses.A_BOLD + curses.A_REVERSE
|
||||||
else:
|
if tick_tock
|
||||||
color = curses.color_pair(2) + curses.A_BOLD
|
else curses.color_pair(2) + curses.A_BOLD
|
||||||
|
)
|
||||||
is_alarm = True
|
is_alarm = True
|
||||||
else:
|
else:
|
||||||
color = curses.color_pair(7)
|
color = curses.color_pair(7)
|
||||||
@@ -237,6 +238,8 @@ def main():
|
|||||||
curses.init_pair(i + 1, i, -1)
|
curses.init_pair(i + 1, i, -1)
|
||||||
start_t = time.time()
|
start_t = time.time()
|
||||||
is_alarm = False
|
is_alarm = False
|
||||||
|
t_old = time.localtime(time.time())
|
||||||
|
tick_tock = False
|
||||||
try:
|
try:
|
||||||
# rows,columns = termsize()
|
# rows,columns = termsize()
|
||||||
curses.cbreak()
|
curses.cbreak()
|
||||||
@@ -258,15 +261,18 @@ def main():
|
|||||||
alphas = math.pi * (f + t_s) / 30.0
|
alphas = math.pi * (f + t_s) / 30.0
|
||||||
alpham = math.pi * t_m / 30.0 + alphas / 60.0
|
alpham = math.pi * t_m / 30.0 + alphas / 60.0
|
||||||
alphah = math.pi * t_h / 6.0 + alpham / 12.0
|
alphah = math.pi * t_h / 6.0 + alpham / 12.0
|
||||||
if t_s == 0:
|
if t_old.tm_min != t.tm_min:
|
||||||
# clear once a minute
|
# clear once a minute
|
||||||
stdscr.clear()
|
stdscr.clear()
|
||||||
|
|
||||||
|
tick_tock = not tick_tock if options.refresh > 1 else t.tm_sec % 2
|
||||||
|
|
||||||
drawcircle(
|
drawcircle(
|
||||||
stdscr,
|
stdscr,
|
||||||
cy,
|
cy,
|
||||||
cx,
|
cx,
|
||||||
r / 2,
|
r / 2,
|
||||||
attr=curses.color_pair(2) + curses.A_BOLD if is_alarm and t_s % 2 == 0 else curses.color_pair(1),
|
attr=curses.color_pair(2) + curses.A_BOLD + curses.A_BLINK if is_alarm else curses.color_pair(1),
|
||||||
)
|
)
|
||||||
if options.seconds:
|
if options.seconds:
|
||||||
drawline(stdscr, cy, cx, alphas, 1, r / 2, "■", curses.color_pair(2))
|
drawline(stdscr, cy, cx, alphas, 1, r / 2, "■", curses.color_pair(2))
|
||||||
@@ -281,7 +287,7 @@ def main():
|
|||||||
drawdigital(stdscr, 7, 1, t, options.ascii)
|
drawdigital(stdscr, 7, 1, t, options.ascii)
|
||||||
else:
|
else:
|
||||||
drawdigital(stdscr, 1, 1, t, options.ascii)
|
drawdigital(stdscr, 1, 1, t, options.ascii)
|
||||||
is_alarm = drawalarms(stdscr, 1, 35, t, alarms)
|
is_alarm = drawalarms(stdscr, 1, 35, t, alarms, tick_tock)
|
||||||
stdscr.refresh()
|
stdscr.refresh()
|
||||||
userinput = readinput(stdscr, options.refresh)
|
userinput = readinput(stdscr, options.refresh)
|
||||||
if userinput == "x":
|
if userinput == "x":
|
||||||
@@ -294,6 +300,7 @@ def main():
|
|||||||
drawline(stdscr, cy, cx, alphas, 1, r / 2, " ", curses.color_pair(2))
|
drawline(stdscr, cy, cx, alphas, 1, r / 2, " ", curses.color_pair(2))
|
||||||
drawline(stdscr, cy, cx, alpham, 1, int(round(r * 0.9) / 2), " ", curses.color_pair(3))
|
drawline(stdscr, cy, cx, alpham, 1, int(round(r * 0.9) / 2), " ", curses.color_pair(3))
|
||||||
drawline(stdscr, cy, cx, alphah, 1, int(round(r * 0.6) / 2), " ", curses.color_pair(7))
|
drawline(stdscr, cy, cx, alphah, 1, int(round(r * 0.6) / 2), " ", curses.color_pair(7))
|
||||||
|
t_old = t
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
curses.nocbreak()
|
curses.nocbreak()
|
||||||
|
|||||||
Reference in New Issue
Block a user