Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.venv
uv.lock
termdown/__pycache__
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies = [
"Pillow",
"python-dateutil",
"windows-curses; platform_system == 'Windows'",
"desktop-notifier"
]

[project.scripts]
Expand Down
6 changes: 6 additions & 0 deletions termdown/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions termdown/modes.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand All @@ -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:
Expand Down