Skip to content

feat: Linux sound playback with auto-detected player (#7) - #10

Open
kenlacroix wants to merge 1 commit into
marekkowalczyk:masterfrom
kenlacroix:feat/linux-sound-playback
Open

feat: Linux sound playback with auto-detected player (#7)#10
kenlacroix wants to merge 1 commit into
marekkowalczyk:masterfrom
kenlacroix:feat/linux-sound-playback

Conversation

@kenlacroix

@kenlacroix kenlacroix commented Jun 21, 2026

Copy link
Copy Markdown

Closes #7.

Adds Linux sound playback, mirroring the existing macOS (afplay) / Windows (winsound) structure — stdlib-only, single-file, with a graceful terminal-bell fallback.

What it does

  • Player detection via shutil.which, probing paplaypw-playaplayffplaycvlc. New 'linux' branch in check_audio(); non-blocking Popen in play_sound() (same as afplay). ffplay/cvlc get the extra args they need to exit cleanly without a window.
  • Default sounds: the freedesktop theme (/usr/share/sounds/freedesktop/stereo/message.oga, complete.oga), since Linux has no universal system-sound path.
  • Config: --sound-player CMD flag plus BREATHE_SOUND_PLAYER / BREATHE_SOUND_INHALE / BREATHE_SOUND_EXHALE env vars.
  • Fallback: if no player or sound file is found, the existing terminal bell is used.
  • Unit tests for the resolution/fallback logic (8 new, 52/52 pass) + README/CLAUDE.md/pyproject updates.

Verified on Linux (PipeWire/PulseAudio): detects paplay, resolves the freedesktop sounds, and plays the cues.

Decisions on the 3 questions from #7

No strong steer came back, so I went with the lighter leans below — each is a one-line change if you'd prefer otherwise:

  1. Config surface — env vars for the sound paths + a single --sound-player override (keeps the line count down). Can add --sound-inhale / --sound-exhale flags for full CLI parity if you'd like.
  2. Defaults — freedesktop sounds with bell fallback, rather than bundling audio files.
  3. Probe orderpaplay (PulseAudio) before pw-play (PipeWire). Easy to flip.

Marking ready for review — happy to adjust any of the above to match your preference.

…zyk#7)

Linux has no universal way to play a sound, so probe for a player on PATH
(paplay, pw-play, aplay, ffplay, cvlc) and use the freedesktop sound theme
by default. Player and sound paths are overridable via --sound-player and
the BREATHE_SOUND_PLAYER / BREATHE_SOUND_INHALE / BREATHE_SOUND_EXHALE env
vars. Falls back to the terminal bell when no player or sound file is found.

Mirrors the existing afplay/winsound structure: non-blocking Popen in
play_sound, a new 'linux' branch in check_audio, stdlib-only, single-file.

Adds unit tests for the resolution/fallback logic and updates README,
CLAUDE.md, and the pyproject Linux classifier.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kenlacroix
kenlacroix marked this pull request as ready for review June 27, 2026 06:50
@artjomsimon

Copy link
Copy Markdown

Tested on Arch Linux, works perfectly. Thank you 👍

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.

Implement proper sound playback support on Linux

2 participants