Add onSessionStart and duringSession hooks#24
Open
ayrtmn wants to merge 12 commits intoBahaaio:mainfrom
Open
Conversation
Add two new hook types to the configuration system:
- onSessionStart: Run commands when a session starts (e.g., play start sound)
- duringSession: Run ambient sounds during session (e.g., rain, ticking)
Both global (top-level) and per-task hooks are supported.
Per-task hooks override global hooks when specified.
Example config:
onSessionStart:
- [afplay, ~/sounds/start.wav]
duringSession:
- [afplay, ~/sounds/rain.mp3]
work:
onStart: [...] # overrides global
during: [...] # overrides global
Remove debug logging added during development.
Bug fix: commands are stored as [command, file, ...] so we need to pass cmd[1] (the file path) instead of cmd[0] (the command itself) to the sound player.
Add PlayCommandLoop and PlayCommandOnce to support commands with multiple arguments like: - [mpv, --no-video, --loop, https://youtube.com/watch?v=...] This enables YouTube audio streams and other complex audio sources for gapless ambient sound playback.
Add Pause() and Resume() methods to sound.Player using mpv IPC socket.
When user pauses the timer, mpv playback is also paused. When resumed,
playback continues from the same position.
Config example:
duringSession:
- ["mpv", "--no-video", "https://youtube.com/watch?v=..."]
Press 'p' to pause - both timer and YouTube audio will pause.
Press 'p' again to resume - both resume from where they left off.
New key binding: - "a" - Toggle during-session audio on/off without pausing timer Workflow: - Space - Pause timer AND audio together - "a" - Toggle audio only (timer keeps running) This allows muting the background music/rain sounds while keeping the timer running, useful when you need silence temporarily. Also fixes mpv IPC socket tracking for reliable pause/resume.
- Add --url (-u) flag to override duringSession audio URL from command line - Fix timer accuracy issues when pausing/resume multiple times - Add pausedElapsed field to track elapsed time during pause - Update help text with --url flag example Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds comprehensive sound support to pomo with seamless audio playback inspired by TomatoBar:
1. New Hooks: onSessionStart and duringSession
Two new hook types for audio feedback:
Both global (top-level) and per-task hooks are supported. Per-task hooks override global hooks.
2. Gapless Audio Playback
Uses
mpvwith--gapless-audioflag for seamless looping without gaps between iterations. Volume defaulted to 80% for better focus.3. Audio Controls
4. Command-line Audio Override
New
--url/-uflag to override duringSession audio URL without editing config:5. Timer Accuracy Fixes
Fixed timer drift issues when pausing/resuming multiple times by properly tracking elapsed time with
pausedElapsedfield.Configuration
Sound Files
Copy sound files from TomatoBar or use your own:
Key Bindings
Spaceapqs+/Up-/DownrImplementation
OnSessionStart,DuringSessionfields with mpv defaultsPlayCommandLoopto support both afplay and mpv with IPC for pause/resumeaudioMuted,pausedElapsed)--urlflagTesting
--urlflag overrides config audio for YouTube/Spotify streams