「Libcanberra」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(文字列「Tips and tricks」を「ヒントとテクニック」に置換)
(文字列「http://freedesktop.org/」を「https://freedesktop.org/」に置換)
5行目: 5行目:
 
{{Related|デスクトップ通知}}
 
{{Related|デスクトップ通知}}
 
{{Related articles end}}
 
{{Related articles end}}
'''Libcanberra''' はイベントサウンドを再生するためのシンプルな抽象インターフェイスです。GNOME などのフリーなデスクトップでイベントサウンドを流すための [http://freedesktop.org/wiki/Specifications/sound-theme-spec XDG Sound Theme and Naming Specifications] を実装しています。詳しい説明は [http://0pointer.de/lennart/projects/libcanberra/ こちら]。
+
'''Libcanberra''' はイベントサウンドを再生するためのシンプルな抽象インターフェイスです。GNOME などのフリーなデスクトップでイベントサウンドを流すための [https://freedesktop.org/wiki/Specifications/sound-theme-spec XDG Sound Theme and Naming Specifications] を実装しています。詳しい説明は [http://0pointer.de/lennart/projects/libcanberra/ こちら]。
   
 
==インストール==
 
==インストール==

2018年2月6日 (火) 23:09時点における版

関連記事

Libcanberra はイベントサウンドを再生するためのシンプルな抽象インターフェイスです。GNOME などのフリーなデスクトップでイベントサウンドを流すための XDG Sound Theme and Naming Specifications を実装しています。詳しい説明は こちら

インストール

Libcanberra は公式リポジトリlibcanberra パッケージでインストールできます。パッケージにはライブラリと GTK+ モジュールが含まれています。

サウンドを再生するためのバックエンドを選択してください:

また、イベントサウンドを聞くためにはサウンドテーマをインストールする必要があります:

設定

デフォルトでは、GTK+ アプリケーションが起動した時に GTK+ モジュールが自動的にロードされます。ユーザーの Gtk 設定ファイルでデフォルトの設定を上書きすることができます:

$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

GNOME では、以上の設定は gnome-settings-daemon によって管理されており、GSettings の org.gnome.desktop.sound スキーマで設定を変更できます。

Systemd

canberra を使って起動・シャットダウン・再起動サウンドを有効にするには、次を実行:

# systemctl enable canberra-system-bootup.service

ヒントとテクニック

canberra アプリの書き方

libcanberra のサウンドイベントは様々なプログラミング言語で簡単に書くことができます。

Bash

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

C

  • 依存パッケージ: libcanberra
  • ビルド: 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

  • 依存パッケージ: libcanberra
  • ビルド依存パッケージ: vala
  • ビルド: 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

  • 依存パッケージ: libcanberra
  • ビルド依存パッケージ: vala
  • ビルド: 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);
	}
}

参照