70 lines
2.4 KiB
Python
70 lines
2.4 KiB
Python
![]() |
import curses
|
||
|
from datetime import datetime
|
||
|
from .utils import init_colors, draw_big_digit
|
||
|
|
||
|
def draw_active_alarms(stdscr, context):
|
||
|
"""Draw the active alarms"""
|
||
|
init_colors()
|
||
|
height, width = stdscr.getmaxyx()
|
||
|
current_time = datetime.now()
|
||
|
|
||
|
# Draw the main clock (original position)
|
||
|
time_str = current_time.strftime("%H:%M:%S")
|
||
|
digit_width = 14
|
||
|
total_width = digit_width * len(time_str)
|
||
|
start_x = (width - total_width) // 2
|
||
|
start_y = (height - 7) // 2 - 4 # Original position from _draw_main_clock
|
||
|
|
||
|
# Draw blinking dot
|
||
|
if int(current_time.timestamp()) % 2 == 0:
|
||
|
stdscr.attron(curses.color_pair(1))
|
||
|
stdscr.addstr(start_y - 1, start_x + total_width - 2, "•")
|
||
|
stdscr.attroff(curses.color_pair(1))
|
||
|
|
||
|
# Green color for big time
|
||
|
stdscr.attron(curses.color_pair(1))
|
||
|
for i, digit in enumerate(time_str):
|
||
|
draw_big_digit(stdscr, start_y, start_x + i * digit_width, digit)
|
||
|
stdscr.attroff(curses.color_pair(1))
|
||
|
|
||
|
# Draw date (as in main clock)
|
||
|
date_str = current_time.strftime("%Y-%m-%d")
|
||
|
date_x = width // 2 - len(date_str) // 2
|
||
|
date_y = height // 2 + 4
|
||
|
stdscr.attron(curses.color_pair(2))
|
||
|
stdscr.addstr(date_y, date_x, date_str)
|
||
|
stdscr.attroff(curses.color_pair(2))
|
||
|
|
||
|
# Get active alarm info
|
||
|
active_alarms = context.get('active_alarms', {})
|
||
|
if not active_alarms:
|
||
|
return
|
||
|
|
||
|
# Get the first (or only) active alarm
|
||
|
alarm_id = list(active_alarms.keys())[0]
|
||
|
alarm_info = active_alarms[alarm_id]
|
||
|
alarm_config = alarm_info['config']
|
||
|
|
||
|
# Format alarm info
|
||
|
alarm_name = alarm_config.get('name', 'Unnamed Alarm')
|
||
|
alarm_time = alarm_config.get('time', 'Unknown Time')
|
||
|
#snooze_count = alarm_info.get('snooze_count', 0)
|
||
|
|
||
|
# Draw alarm info under the clock
|
||
|
info_y = start_y + 8 # Position below the clock
|
||
|
#alarm_str = f"[ {alarm_name} - {alarm_time} - Snoozed: {snooze_count}x ]"
|
||
|
alarm_str = f"[ {alarm_name} - {alarm_time} ]"
|
||
|
alarm_x = max(0, width // 2 - len(alarm_str) // 2)
|
||
|
alarm_y = date_y - 2 # Just above the date
|
||
|
|
||
|
# Center the alarm info
|
||
|
info_x = max(0, width // 2 - len(alarm_str) // 2)
|
||
|
|
||
|
# Draw with green color
|
||
|
stdscr.attron(curses.color_pair(1))
|
||
|
stdscr.addstr(alarm_y, alarm_x, alarm_str)
|
||
|
stdscr.attroff(curses.color_pair(1))
|
||
|
|
||
|
# Instructions
|
||
|
stdscr.addstr(height - 2, width // 2 - 15, "S: Snooze D: Dismiss")
|