How to Create a Custom Sound Scheme on Linux UbuntuCustomizing your Ubuntu sound scheme breathes personality into your system and can improve usability by making notifications, errors, and events more distinguishable. This guide walks you through planning, preparing, creating, installing, and testing a custom sound scheme on modern Ubuntu (GNOME-based) systems. Steps include choosing audio files, converting formats, organizing a sound theme, configuring desktop entries, and applying the scheme system-wide or per-user.
Overview: What a sound scheme is and where it’s used
A sound scheme (sound theme) is a collection of audio files mapped to desktop events (notification, error, logout, login, etc.). Desktop environments like GNOME use the XDG Sound Theme specification so themes can be switched without rewriting application code. Sounds can be applied system-wide (for all users) or per-user (only your account).
Prerequisites
- Ubuntu 20.04 or newer (GNOME Shell). Steps mostly apply to other Debian-based distributions and many Linux desktop environments that support the XDG sound theme spec.
- Basic terminal familiarity.
- Tools:
- ffmpeg or sox (for format conversion).
- paplay or canberra-gtk-play (for testing).
- A text editor (gedit, nano, or code).
- Optionally, sound-theme-utils (for packaging helpers).
Install common tools:
sudo apt update sudo apt install ffmpeg libcanberra-gtk-module libcanberra-gtk3-module sound-theme-utils
Step 1 — Plan your scheme
List the events you want to customize. Common event names (GNOME/CANBERRA) include:
- startup/login
- logout/shutdown
- message/notification
- dialog-error
- dialog-warning
- bell
- complete (task finished)
- low-battery
Decide on a consistent audio style (short chimes, realistic sounds, retro blips) and volume levels. Keep most sounds short (0.2–2.0 seconds) so they’re not intrusive.
Step 2 — Source and prepare audio files
- Use royalty-free samples or create your own recordings. Sites like Freesound and public domain libraries are good sources—ensure proper licensing.
- Prefer lossless or high-bitrate files initially. Convert to OGG Vorbis for best compatibility with desktop sound themes.
Batch convert to OGG and normalize volume using ffmpeg:
mkdir -p ~/sound-schemes/mytheme/sounds for f in ~/Downloads/*.wav; do name=$(basename "$f" .wav) ffmpeg -y -i "$f" -ar 44100 -ac 2 -vn -b:a 128k -af "loudnorm" "~/sound-schemes/mytheme/sounds/${name}.ogg" done
Notes:
- Use 44100 Hz, stereo; 64–128 kbps OGG is usually fine.
- Trim or fade sounds to remove clipping.
Step 3 — Follow the XDG sound-theme structure
Create the folder layout that desktop environments expect. For a local, per-user theme:
mkdir -p ~/.local/share/sounds/MyTheme/{sounds,metadata}
For system-wide installation (available to all users), use:
sudo mkdir -p /usr/share/sounds/MyTheme/{sounds,metadata}
Copy your .ogg files into the sounds directory.
Step 4 — Create metadata for your theme
Create a metadata file at ~/.local/share/sounds/MyTheme/index.theme (or /usr/share/…). Example:
[Sound Theme] Name=MyTheme Directories=sounds [MyTheme] OutputProfile=stereo
This minimal file identifies the theme. Some systems use more detailed keys, but this works for GNOME.
Step 5 — Map sound files to event names
File names should match the event IDs used by libcanberra and the desktop. Use descriptive names like dialog-error.ogg, message-new-email.ogg, etc.
Common mapping examples:
- dialog-error.ogg
- dialog-warning.ogg
- message.ogg or message-new-email.ogg
- complete.ogg
- bell.ogg
- system-login.ogg (or login.ogg)
- system-logout.ogg (or logout.ogg)
If you need non-standard names, you can create a GTK/Canberra configuration or use dconf to remap certain events, but matching names is simplest.
Step 6 — Test sounds locally
Use paplay or canberra-gtk-play to test individual files:
paplay ~/.local/share/sounds/MyTheme/sounds/dialog-error.ogg # or canberra-gtk-play -f ~/.local/share/sounds/MyTheme/sounds/dialog-error.ogg
To trigger event-name playback via libcanberra:
canberra-gtk-play --id="dialog-error" --description="Test error sound"
If the theme isn’t yet active, playing the file directly verifies it sounds correct.
Step 7 — Apply the theme
GNOME doesn’t provide a GUI switcher for sound themes by default. To set your theme for your session:
- Add the theme name to the XDG_CURRENT_DESKTOP environment or use the GTK sound theme setting via GSettings (dconf). The key is org.gnome.desktop.sound theme-name.
Set via gsettings:
gsettings set org.gnome.desktop.sound theme-name 'MyTheme'
Confirm:
gsettings get org.gnome.desktop.sound theme-name
Log out and back in (or restart the gnome-shell) for changes to take full effect.
For system-wide default, place the theme under /usr/share/sounds and ensure the name is visible to other desktops. Some display managers may cache sound settings — a reboot ensures system-wide application.
Step 8 — Advanced: conditional sounds, per-application rules, and volume control
- Per-application mappings: Some apps let you choose sound files directly (e.g., Pidgin historically). Otherwise, apps call standard event IDs.
- Scripting events: Use canberra-gtk-play in scripts to announce events from custom programs. Example:
canberra-gtk-play --id="complete" --description="Backup finished"
- Volume: Desktop environments respect system volume. Use pactl or amixer in scripts to temporarily adjust playback volume if needed.
Step 9 — Packaging and sharing your theme
Create a tarball for distribution:
cd ~/.local/share/sounds tar -czf MyTheme-1.0.tar.gz MyTheme
Include a README with license details and installation instructions:
- Per-user: extract to ~/.local/share/sounds/
- System-wide: extract to /usr/share/sounds/ and run update-alternatives if needed.
Optionally, create a DEB package for easier installation on Debian/Ubuntu.
Troubleshooting
- Theme not applied: check gsettings key, ensure index.theme exists and name matches, log out/in.
- Sounds not playing: ensure files are OGG, correct sample rate, and file permissions allow reading.
- Conflicting names: if multiple themes define the same event, the active theme takes precedence.
- Wayland vs X11: sound themes work the same; issues usually stem from desktop settings or app behavior, not display server.
Tips and UX considerations
- Keep sounds short and unobtrusive; repetitive loud sounds annoy users.
- Use auditory cues sparingly — reserve distinctive sounds for important events.
- Provide a mute or low-volume variant for certain events (e.g., notifications during meetings).
- Test across different desktop environments (GNOME, XFCE, KDE) if sharing the theme.
Example: Minimal sample theme
Folder layout: ~/.local/share/sounds/MyTheme/
- index.theme
- sounds/
- dialog-error.ogg
- message.ogg
- complete.ogg
- bell.ogg
index.theme:
[Sound Theme] Name=MyTheme Directories=sounds [ sounds ] OutputProfile=stereo
Apply:
gsettings set org.gnome.desktop.sound theme-name 'MyTheme' canberra-gtk-play --id="complete" --description="Test"
Creating a custom Ubuntu sound scheme is a satisfying way to personalize your desktop and make events more informative. With the XDG sound-theme structure, a few OGG files, and a short metadata file, you can build and share a polished sound theme that fits your workflow.
Leave a Reply