fix(beep): bundle fallback chime for Linux distros without freedesktop sounds#1535
Merged
tdewey-rpi merged 3 commits intoMar 6, 2026
Conversation
tdewey-rpi
reviewed
Mar 4, 2026
Collaborator
|
What's the copyright story on the chime.wav? Are you able to certify it's your own product and you're able to assign usage rights to the project? |
Contributor
Author
|
Good catch, thanks! I initially assumed the chime was from @0xDE57's repo (https://github.com/0xDE57/raspberry-chime, CC0 1.0), but after your comment I double-checked and it turned out to be a different file entirely Replaced it now with |
Collaborator
|
Confirming we're now in a place to accept this. Thanks for the contributions both! |
…p sounds
On Linux distros that don't ship freedesktop sound theme files (e.g. Arch),
the "Play sound when finished" feature fails because the hardcoded paths
/usr/share/sounds/freedesktop/stereo/{complete,bell}.oga don't exist.
This adds:
- More system sound search paths (Ubuntu Yaru, KDE Ocean, GNOME legacy)
- A bundled 26KB WAV chime as last-resort fallback, extracted to a temp
file so existing playback commands (pw-play, aplay, pactl) can use it
- PID-based temp filename and restrictive permissions for security
(rpi-imager runs as root via pkexec)
- Automatic cleanup of the temp file on application exit
The bundled chime is a synthetically generated 880Hz sine wave (0.3s).
Closes raspberrypi#1449
PID allocation is predictable, making symlink attacks easier. Use QUuid::createUuid() for an unpredictable temp filename.
Use 314A.wav (314Hz root note, "pi" themed) from https://github.com/0xDE57/raspberry-chime, licensed under CC0 1.0. Original contribution by @0xDE57 in issue raspberrypi#1449.
2a4797f to
63596b7
Compare
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.
std::atexit()Root Cause
On Linux distros that don't ship freedesktop sound theme files (e.g. Arch),
findSoundFile()returnsnullptrbecause only two paths were checked:/usr/share/sounds/freedesktop/stereo/complete.oga/usr/share/sounds/freedesktop/stereo/bell.ogaThis caused
isBeepAvailable()to returnfalse(unlesscanberra-gtk-playorbeepwas installed), and thebeep()function to fail with "Failed to open sound file." even whenpw-playoraplaywas available.The fix adds three more distro-specific paths, and when none exist, extracts a bundled WAV chime from Qt resources to a temp file. This enables the existing
pw-play/aplay/pactlfallback chain to work on any Linux system.Security considerations
Since rpi-imager runs as root via pkexec, temp file handling is security-sensitive:
QFile::remove()beforecopy()prevents following pre-existing symlinksReadOwner | WriteOwnerpermissions restricts access to root onlystd::atexit()cleanup removes the temp file on exitCloses #1449