Difference between revisions of "Libcanberra"

From ArchWiki
Jump to: navigation, search
(Syntax)
(update link(s) (avoid redirect))
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
[[Category:Development]]
 
[[Category:Development]]
{{Article summary start|Summary}}
+
{{Related articles start}}
{{Article summary text|This article discusses how to install and configure libcanberra.}}
+
{{Related|GTK+}}
{{Article summary heading|Related}}
+
{{Related|Libnotify}}
{{Article summary wiki|GTK+}}
+
{{Related articles end}}
{{Article summary wiki|Libnotify}}
+
{{Article summary end}}
+
 
+
 
'''Libcanberra''' is a simple abstract interface for playing event sounds. It implements the [http://freedesktop.org/wiki/Specifications/sound-theme-spec XDG Sound Theme and Naming Specifications] for generating event sounds on free desktops, such as GNOME. Further description [http://0pointer.de/lennart/projects/libcanberra/ here]
 
'''Libcanberra''' is a simple abstract interface for playing event sounds. It implements the [http://freedesktop.org/wiki/Specifications/sound-theme-spec XDG Sound Theme and Naming Specifications] for generating event sounds on free desktops, such as GNOME. Further description [http://0pointer.de/lennart/projects/libcanberra/ here]
  
 
==Installation==
 
==Installation==
  
Libcanberra can be installed with the package {{Pkg|libcanberra}}, available in the [[Official Repositories]]. It contains the library and a GTK+ module.
+
Libcanberra can be installed with the package {{Pkg|libcanberra}}, available in the [[Official repositories]]. It contains the library and a GTK+ module.
  
 
You have to choose a backend to play sounds:
 
You have to choose a backend to play sounds:
 
*[[ALSA]] backend is included in {{Pkg|libcanberra}} package
 
*[[ALSA]] backend is included in {{Pkg|libcanberra}} package
*[[GStreamer]] backend can be installed with package {{Pkg|libcanberra-gstreamer}}, available in the [[Official Repositories]].
+
*[[GStreamer]] backend can be installed with package {{Pkg|libcanberra-gstreamer}}, available in the [[Official repositories]].
*[[PulseAudio]] backend can be installed with package {{Pkg|libcanberra-pulse}}, available in the [[Official Repositories]].
+
*[[PulseAudio]] backend can be installed with package {{Pkg|libcanberra-pulse}}, available in the [[Official repositories]].
 
*[[OSS]] backend can be installed with the package {{AUR|libcanberra-oss}}, available in the [[Arch User Repository]].
 
*[[OSS]] backend can be installed with the package {{AUR|libcanberra-oss}}, available in the [[Arch User Repository]].
  
 
Also, you have to install a sound theme in order to hear any event sound:
 
Also, you have 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 {{Pkg|sound-theme-freedesktop}}, available in the [[Official Repositories]].
+
*The default sound theme is 'freedesktop', which can be installed with the package {{Pkg|sound-theme-freedesktop}}, available in the [[Official repositories]].
 
*Alternatively, you can install {{AUR|ubuntu-sounds}}, available in the [[Arch User Repository]].
 
*Alternatively, you can install {{AUR|ubuntu-sounds}}, available in the [[Arch User Repository]].
  
Line 30: Line 27:
  
 
In GNOME, these settings are managed by gnome-settings-daemon, and the configuration is available in GSettings under org.gnome.desktop.sound schema.
 
In GNOME, these settings are managed by gnome-settings-daemon, and the configuration is available in GSettings under org.gnome.desktop.sound schema.
 +
 +
==Systemd==
 +
To enable bootup, shutdown and reboot sounds using canberra, run:
 +
 +
{{ic|<nowiki># systemctl enable canberra-system-bootup.service</nowiki>}}
  
 
==Tips and tricks==
 
==Tips and tricks==

Revision as of 11:59, 24 February 2014

Related articles

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=freedesktop

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

Systemd

To enable bootup, shutdown and reboot sounds using canberra, run:

# systemctl enable canberra-system-bootup.service

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

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

C

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

Genie

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

Vala

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

See also