diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..01b5d8b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.venv +uv.lock +termdown/__pycache__ diff --git a/pyproject.toml b/pyproject.toml index 1b9c3c0..87238fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,6 +36,7 @@ dependencies = [ "Pillow", "python-dateutil", "windows-curses; platform_system == 'Windows'", + "desktop-notifier" ] [project.scripts] diff --git a/termdown/cli.py b/termdown/cli.py index 772bbf1..8744f8c 100644 --- a/termdown/cli.py +++ b/termdown/cli.py @@ -163,6 +163,12 @@ def wrapper(*args, **kwargs): parser.add_argument( "--no-art", action="store_true", help="Don't use ASCII art for display" ) +parser.add_argument( + "-n", + "--notification", + metavar="NOTIFICATION_TEXT", + help="Sends notification when the countdown stops (Not avalible in TTY)", +) parser.add_argument( "--no-text-magic", action="store_true", diff --git a/termdown/modes.py b/termdown/modes.py index 0aa9ada..2297ff9 100644 --- a/termdown/modes.py +++ b/termdown/modes.py @@ -1,4 +1,6 @@ import os +import asyncio +from desktop_notifier import DesktopNotifier from curses import beep from datetime import datetime, timedelta, timezone from math import ceil @@ -24,6 +26,9 @@ parse_timestr, ) +async def notify(message): + notifier = DesktopNotifier() + await notifier.send(title="Termdown", message=message) def countdown(ui, args): target_time = parse_timestr(args.timespec) @@ -38,6 +43,8 @@ def countdown(ui, args): # If seconds_left is zero or negative, immediately break to handle the # "finished" state. This prevents displaying "0" for an entire second # while waiting for the next tick. + if not args.notification == None: + asyncio.run(notify(args.notification)) break if args.alt_format: