Libcanberra
Libcanberra is a simple abstract interface for playing event sounds. It implements the XDG Sound Theme and Naming Specifications for generating event sounds on free desktops, such as GNOME. Further description here
Installation
Libcanberra can be installed with the package libcanberra. libcanberra no longer requires any backends for ALSA, pulseaudio or gstreamer, as they are now built in to the libcanberra package.
It is necessary to install a sound theme in order to hear any event sound:
- The default sound theme is 'freedesktop', which can be installed with the package sound-theme-freedesktop.
- Alternatively, search for "sound-theme" in the official repositories or the Arch User Repository.
Configuration
By default, the GTK module is loaded automatically when a GTK application launched. You can overwrite the default settings in the user's GtkSettings file:
$HOME/.gtkrc-2.0 and $XDG_CONFIG_HOME/gtk-3.0/settings.ini
gtk-enable-event-sounds=true gtk-enable-input-feedback-sounds=true gtk-sound-theme-name=freedesktop
In GNOME, these settings are managed by gnome-settings-daemon, and the configuration is available in GSettings under the org.gnome.desktop.sound
schema.
systemd
To enable bootup, shutdown and reboot sounds using canberra, enable canberra-system-bootup.service
.
Usage in programming
You can write your own libcanberra sound events easily in many programming languages using GSound through GObject-Introspection, or you can simply use bash.
Bash
- Dependency: libcanberra
Genie
- Dependency: libcanberra
- Makedependency: vala
- Build with:
valac --pkg libcanberra hello_world.gs
- Dependency:
- Makedependency: vala
- Build with:
JavaScript
- Dependencies: ,
Lua
- Dependencies: ,
Perl
- Dependencies: ,
Python
- Dependencies: , python-gobject
hello_world.py
#!/usr/bin/python import gi gi.require_version('GSound', '1.0') from gi.repository import GLib, GSound hello = GSound.Context() hello.init() hello.play_simple({GSound.ATTR_EVENT_ID: "phone-incoming-call", GSound.ATTR_EVENT_DESCRIPTION: "hello world"}) GLib.usleep(2000000)
Ruby
- Dependencies: ,
Vala
- Dependency: libcanberra
- Makedependency: vala
- Build with:
- Dependency:
- Makedependency: vala
- Build with: