Libcanberra

From ArchWiki
Revision as of 23:56, 10 January 2012 by City-busz (Talk | contribs) (fix related pages)

Jump to: navigation, search

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Summary help replacing me
This article discusses how to install and configure libcanberra. Libcanberra is a small and lightweight library that implements the XDG Sound Theme Specification. This article covers how to get libcanberra on your system and how to use it for application development.
Related
GNOME
Libnotify

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, available in the Official Repositories. It contains the library and a GTK+ module.

You have to choose a backend to play sounds:

Also, you have 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 default settings in 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=freedestop

In GNOME, these settings are managed by gnome-settings-daemon, and the configuration is available in GSettings under org.gnome.desktop.sound schema.

Tips and tricks

Write your own canberra app

You can write your own libcanberra sound events easily in some programming languages, or you can simply use bash.

Bash

hallo_world.sh
#!/bin/bash
canberra-gtk-play -i phone-incoming-call -d "Hallo world"

C

  • Dependency: libcanberra
  • Build with: gcc -o hallo_world `pkg-config --cflags --libs glib-2.0 libcanberra` hallo_world.c
hallo_world.c
#include <glib.h>
#include <canberra.h>
void main () {
	ca_context * Hallo;
	ca_context_create (&Hallo);
	ca_context_play (Hallo, 0,
		CA_PROP_EVENT_ID, "phone-incoming-call",
		CA_PROP_EVENT_DESCRIPTION, "Hallo world",
		NULL);
	g_usleep (2000000);
}

Genie

  • Dependency: libcanberra
  • Makedependency: vala
  • Build with: valac --pkg libcanberra hallo_world.gs
hallo_world.gs
uses
	Canberra
init
	Hallo: Context
	Context.create(out Hallo)
	Hallo.play (0,
		PROP_EVENT_ID, "phone-incoming-call",
		PROP_EVENT_DESCRIPTION, "Hallo world")
	Thread.usleep (2000000)

Vala

  • Dependency: libcanberra
  • Makedependency: vala
  • Build with: valac --pkg libcanberra hallo_world.vala
hallo_world.vala
using Canberra;
public class HalloWorld {
	static void main () {
	Context Hallo;
	Context.create(out Hallo);
	Hallo.play (0,
		PROP_EVENT_ID, "phone-incoming-call",
		PROP_EVENT_DESCRIPTION, "Hallo world");
	Thread.usleep (2000000);
	}
}

See also