Skip to content

feat(cli): Linux desktop notification with estimated reading time - #25

Merged
DavidTbilisi merged 1 commit into
masterfrom
feat/linux-start-notification
Nov 1, 2026
Merged

DavidTbilisi merged 1 commit into
masterfrom
feat/linux-start-notification

Conversation

@DavidTbilisi

Copy link
Copy Markdown
Owner

Summary

Runs started from a hotkey or with tts-ka cb have no visible terminal, so there was no way to tell how long a read would take. Now, whenever audio will play on Linux, the CLI shows a notify-send notification as it starts:

🔊 Reading ~10 min
1,150 words · ka · done ≈ 15:51

  • Estimate: the estimate uses each language's speaking speed, measured from real edge-tts output: en ≈ 180, ru ≈ 130, ka / ka-m ≈ 115 words/min (notify.SPEECH_WPM). It is scaled by --rate and counts only text that will be spoken (replace_not_readable drops code blocks and URLs first). The chunking constant WPM = 160 would make Georgian estimates about 40% too short, so it's left for chunk sizing only.
  • "done ≈" time: shown for reads of a minute or more. It covers playback only, not the time to generate the audio.
  • One notification at a time: a new read replaces the previous notification (x-canonical-private-synchronous hint) instead of stacking them.
  • When it's skipped: with --no-play, --live, study mode and the GUI. It's also skipped on systems other than Linux, and when notify-send isn't installed.
  • Turning it off: --no-notify, TTS_KA_NOTIFY=0, or "notify": false in the config file (mapped to the env var in apply_env_from_config).
  • Errors: sending never raises. notify-send runs with a 3 s timeout, and OS or subprocess errors are swallowed.
  • Other outputs: the terminal summary line now ends with ~N min, and the --json start event includes estimated_seconds.
  • Docs: updated the README (flag, env var, config key), --help-full, shell completions and CLAUDE.md.

Test plan

  • pytest passes: 833 tests, 87.8% coverage
  • New tests/test_notify.py covers rate parsing, per-language estimates, duration formatting, the end time, enable/disable via platform, binary and env, the config mapping, the notify-send argv, and errors never raising
  • New CLI cases in tests/test_main.py: notification sent by default and with --stream; not sent with --no-play or --no-notify
  • The autouse conftest._no_desktop_notifications fixture stops the test suite from showing real notifications on the desktop
  • Sent a real notification on Fedora 44 (GNOME) and it appeared
  • mypy src/TTS_ka/notify.py is clean

🤖 Generated with Claude Code

Hotkey / `tts-ka cb` runs have no visible terminal, so there was no way to
know how long a read would take. When audio will play, main now sends a
notify-send bubble ("🔊 Reading ~10 min · 1,150 words · ka · done ≈ 15:51").

The estimate uses measured per-language edge-tts speeds (en 180, ru 130,
ka 115 wpm) on the sanitized text, scaled by --rate; the chunking WPM of
160 would be ~40% short for Georgian. Each read replaces the previous
bubble. Off with --no-notify, TTS_KA_NOTIFY=0 or "notify": false.

The CLI banner and the --json start event also carry the estimate. Tests
disable notifications globally so they never pop on the dev desktop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DavidTbilisi
DavidTbilisi merged commit ddb539b into master Nov 1, 2026
6 checks passed
@DavidTbilisi
DavidTbilisi deleted the feat/linux-start-notification branch November 1, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant