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:

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

C

  • Dependency:
  • Build with:

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

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:
  • Makedependency: vala
  • Build with:
gollark: You have me MUTED?
gollark: gollark, in all cases.
gollark: ```pythondef macron(input): while True: exec(input)```
gollark: Wow, that's such an implementation.
gollark: Oh.

See also

This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.