「デスクトップ通知」の版間の差分
細 (1版 をインポートしました) |
(同期) |
||
| 5行目: | 5行目: | ||
[[ru:Desktop notifications]] |
[[ru:Desktop notifications]] |
||
{{Related articles start}} |
{{Related articles start}} |
||
| − | {{ |
+ | {{Related|GTK+}} |
{{Related|Libcanberra}} |
{{Related|Libcanberra}} |
||
{{Related articles end}} |
{{Related articles end}} |
||
| 12行目: | 12行目: | ||
==Libnotify== |
==Libnotify== |
||
| − | Libnotify は [[ |
+ | Libnotify は [[GTK+]] や [[Qt]] アプリケーションのサポートを提供する [http://developer.gnome.org/notification-spec/ Desktop Notifications Specification] の実装で特定のデスクトップに依存していません: [[Evolution]] や [[Pidgin]] など多数のオープンソースアプリによって使用されています。Libnotify は[[公式リポジトリ]]にある {{Pkg|libnotify}} パッケージでインストールすることが可能です。 |
libnotify を使うには、[[#通知サーバー|通知サーバー]]をインストールする必要があります。 |
libnotify を使うには、[[#通知サーバー|通知サーバー]]をインストールする必要があります。 |
||
| 21行目: | 21行目: | ||
以下のデスクトップ環境では通知を表示するためにそれぞれ独自の実装を使っており、置き換えることができません。通知サーバーはログイン時に自動で起動し DBus によってアプリケーションからの通知を受け取ります。 |
以下のデスクトップ環境では通知を表示するためにそれぞれ独自の実装を使っており、置き換えることができません。通知サーバーはログイン時に自動で起動し DBus によってアプリケーションからの通知を受け取ります。 |
||
| + | * [[Cinnamon]] は通知サーバーを備えており、通知は画面の右上に表示されます。 |
||
| − | * [[Avant Window Navigator]] には {{AUR|awn-extras-applets}} による通知デーモンアプレットがあります。 |
||
| − | * [[ |
+ | * [[Enlightenment]] は Notification 拡張を通して通知サーバーを提供しています。通知オプションは[[Enlightenment#通知|設定]]が可能です。 |
| − | * [[ |
+ | * [[GNOME]] は通知サーバーを備えており、通知は画面の上部に表示されます。 |
| − | * [[ |
+ | * [[KDE]] は通知サーバーを備えており、通知は画面の右下に表示されます。 |
| − | * [[KDE|KDE]] は {{Pkg|kdebase-runtime}} パッケージに入っている '''knotify4''' を使って通知を表示します。通知は画面の右下に表示されます。 |
||
===スタンドアロン=== |
===スタンドアロン=== |
||
| − | 他のデスクトップ環境では、DBus で初めて呼ばれた時に通知サーバー |
+ | 他のデスクトップ環境では、ウィンドウマネージャやデスクトップ環境の自動実行を使って通知サーバーを起動する必要があります (DBus で初めて呼ばれた時に通知サーバーを起動させることもできますが、グローバルな設定が必要です)。 |
| + | |||
| − | * {{pkg|dunst}} は [[dwm]] などの最小主義のウィンドウマネージャによく似合うように作られた最小主義の通知デーモンです。 |
||
| + | 通知サーバーは以下から選ぶことができます: |
||
| − | * {{pkg|notification-daemon}} は [[GNOME Flashback|GNOME Flashback]] が使っている通知デーモンです。デフォルトでは D-Bus サービスファイルを持っていません。GNOME Flashback 以外から使うには、以下のファイルを作成してください: |
||
| + | |||
| − | {{hc|/usr/share/dbus-1/services/org.gnome.Notifications.service| |
||
| + | * {{App|[[Avant Window Navigator]]|AWN で使うことができる通知デーモンアプレット。|https://github.com/p12tic/awn-extras|{{AUR|awn-extras-applets}}}} |
||
| − | [D-BUS Service] |
||
| + | * {{App|Deepin Notifications|[[Deepin]] の通知サーバー。|https://github.com/linuxdeepin/deepin-notifications|{{pkg|deepin-notifications}}}} |
||
| − | Name=org.freedesktop.Notifications |
||
| + | * {{App|Dunst|[[dwm]] などのミニマルなウィンドウマネージャにうってつけの Linux 用の最小通知デーモン。|http://www.knopwob.org/dunst/|{{pkg|dunst}}}} |
||
| − | Exec=/usr/lib/notification-daemon-1.0/notification-daemon}} |
||
| + | * {{App|LXQt Notification Daemon|[[LXQt]] の通知サーバー。|https://github.com/lxde/lxqt-notificationd|{{pkg|lxqt-notificationd}}}} |
||
| − | * {{Pkg|mate-notification-daemon}} は [[MATE|MATE]] の通知サーバーで、公式リポジトリからインストールできます。 |
||
| + | * {{App|Notification Daemon|[[GNOME Flashback]] によって使われている通知サーバー。|https://github.com/GNOME/notification-daemon|{{pkg|notification-daemon}}}} |
||
| − | * {{Pkg|notify-osd}} は [[Unity|Unity]] の通知サーバーで、公式リポジトリからインストールできます。 |
||
| + | :{{ic|/usr/lib/notification-daemon-1.0/notification-daemon}} で手動で起動できます。 |
||
| − | * {{AUR|statnot}} は小さくて軽量な通知デーモンで、ルートウィンドウのタイトルや標準出力、FIFO パイプに通知を出力することができ、タイル型ウィンドウマネージャと上手く統合されます。[[Arch User Repository|Arch User Repository]] または [https://github.com/halhen/statnot git リポジトリ]から利用できます。 |
||
| + | * {{App|MATE Notification Daemon|[[MATE]] の通知サーバー。|https://github.com/mate-desktop/mate-notification-daemon/|GTK+ 2: {{Pkg|mate-notification-daemon}}, GTK+ 3: {{Pkg|mate-notification-daemon-gtk3}}}} |
||
| − | * {{AUR|twmn-git}} はタイル型ウィンドウマネージャのための通知システムです。[[Arch User Repository|Arch User Repository]] または [https://github.com/sboli/twmn git リポジトリ]から利用できます。 |
||
| + | * {{App|Notify OSD|[[Unity]] の通知サーバー。|https://launchpad.net/notify-osd|{{Pkg|notify-osd}}}} |
||
| − | * {{Pkg|xfce4-notifyd}} は [[Xfce|Xfce]] の通知サーバーで、公式リポジトリからインストールできます。 |
||
| + | * {{App|statnot|小さくて軽量な通知デーモン。ルートウィンドウのタイトルや標準出力、FIFO パイプなどに通知を出力できるので、タイル型ウィンドウマネージャと相性がとても良いです。|https://github.com/halhen/statnot|{{AUR|statnot}}}} |
||
| + | * {{App|twmn|タイル型ウィンドウマネージャ向けの通知システム。|https://github.com/sboli/twmn|{{AUR|twmn-git}}}} |
||
| + | * {{App|Xfce Notification Daemon|[[Xfce]] の通知サーバー。|http://goodies.xfce.org/projects/applications/xfce4-notifyd|{{Pkg|xfce4-notifyd}}}} |
||
:{{Tip|xfce4-notifyd を設定するには、ターミナルから次のコマンドを実行してください: {{ic|xfce4-notifyd-config}}。}} |
:{{Tip|xfce4-notifyd を設定するには、ターミナルから次のコマンドを実行してください: {{ic|xfce4-notifyd-config}}。}} |
||
| 56行目: | 58行目: | ||
}} |
}} |
||
| + | {{Tip| |
||
| − | {{Tip|利用可能なアイコンは[http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html ここ]から参照できます。}} |
||
| + | * 利用可能なアイコンは[http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html ここ]から参照できます。 |
||
| + | * root で実行するバックグラウンドスクリプトからデスクトップ通知を送信するには ({{ic|''X_user''}} は X を実行するユーザーに置き換えてください): {{ic|1=# sudo -u ''X_user'' DISPLAY=:0 notify-send 'Hello world!' 'This is an example notification.'}}。}} |
||
'''Boo''' |
'''Boo''' |
||
| 81行目: | 85行目: | ||
{{hc|hello_world.c|2= |
{{hc|hello_world.c|2= |
||
#include <libnotify/notify.h> |
#include <libnotify/notify.h> |
||
| − | + | int main() { |
|
notify_init ("Hello world!"); |
notify_init ("Hello world!"); |
||
NotifyNotification * Hello = notify_notification_new ("Hello world", "This is an example notification.", "dialog-information"); |
NotifyNotification * Hello = notify_notification_new ("Hello world", "This is an example notification.", "dialog-information"); |
||
| 87行目: | 91行目: | ||
g_object_unref(G_OBJECT(Hello)); |
g_object_unref(G_OBJECT(Hello)); |
||
notify_uninit(); |
notify_uninit(); |
||
| + | return 0; |
||
} |
} |
||
}} |
}} |
||
| 92行目: | 97行目: | ||
'''C++''' |
'''C++''' |
||
| − | * 依存パッケージ: |
+ | * 依存パッケージ: {{AUR|libnotifymm}} |
* ビルド: {{Ic|g++ -o hello_world `pkg-config --cflags --libs libnotifymm-1.0` hello_world.cc}} |
* ビルド: {{Ic|g++ -o hello_world `pkg-config --cflags --libs libnotifymm-1.0` hello_world.cc}} |
||
| 100行目: | 105行目: | ||
Notify::init("Hello world!"); |
Notify::init("Hello world!"); |
||
Notify::Notification Hello("Hello world", "This is an example notification.", "dialog-information"); |
Notify::Notification Hello("Hello world", "This is an example notification.", "dialog-information"); |
||
| − | + | Hello.show(); |
|
| + | return 0; |
||
} |
} |
||
}} |
}} |
||
| 126行目: | 132行目: | ||
* 依存パッケージ: {{Pkg|notify-sharp-3}} |
* 依存パッケージ: {{Pkg|notify-sharp-3}} |
||
| − | * ビルドするのに必要なパッケージ: |
+ | * ビルドするのに必要なパッケージ: {{AUR|cobra}} |
* ビルド: {{ic|cobra -c hello_world}} |
* ビルド: {{ic|cobra -c hello_world}} |
||
* 実行: {{ic|mono hello_world.exe}} |
* 実行: {{ic|mono hello_world.exe}} |
||
| − | {{hc|hello_world. |
+ | {{hc|hello_world.cobra|<nowiki>@args -pkg:notify-sharp-3.0 |
use Notifications |
use Notifications |
||
class HelloWorld |
class HelloWorld |
||
| 143行目: | 149行目: | ||
* 依存パッケージ: {{Pkg|notify-sharp-3}} |
* 依存パッケージ: {{Pkg|notify-sharp-3}} |
||
| − | * ビルドするのに必要なパッケージ: |
+ | * ビルドするのに必要なパッケージ: {{AUR|fsharp}} |
* ビルド: {{ic|fsharpc -r:notify-sharp.dll -I:/usr/lib/mono/notify-sharp-3.0/ -I:/usr/lib/mono/gtk-sharp-3.0/ hello_world.fs}} |
* ビルド: {{ic|fsharpc -r:notify-sharp.dll -I:/usr/lib/mono/notify-sharp-3.0/ -I:/usr/lib/mono/gtk-sharp-3.0/ hello_world.fs}} |
||
* 実行: {{ic|mono hello_world.exe}} |
* 実行: {{ic|mono hello_world.exe}} |
||
| 168行目: | 174行目: | ||
init |
init |
||
Notify.init ("Hello world") |
Notify.init ("Hello world") |
||
| − | var Hello=new Notification ("Hello world!","This is an example notification.","dialog-information") |
+ | var Hello=new Notify.Notification ("Hello world!","This is an example notification.","dialog-information") |
Hello.show () |
Hello.show () |
||
| + | }} |
||
| + | |||
| + | '''Go''' |
||
| + | |||
| + | * 依存パッケージ: {{Pkg|libnotify}} |
||
| + | * ビルドするのに必要なパッケージ: {{AUR|go-notify-git}} |
||
| + | * ビルド: {{ic|go build hello_world.go}} |
||
| + | * 実行: {{ic|go run hello_world.go}} |
||
| + | |||
| + | {{hc|hello_world.go|2= |
||
| + | package main |
||
| + | import ("github.com/mqu/go-notify") |
||
| + | |||
| + | func main() { |
||
| + | notify.Init("Hello world") |
||
| + | hello := notify.NotificationNew("Hello World!", "This is an example notification.","dialog-information") |
||
| + | hello.Show() |
||
| + | } |
||
}} |
}} |
||
'''Groovy''' |
'''Groovy''' |
||
| − | * 依存パッケージ: {{Pkg|groovy}}, |
+ | * 依存パッケージ: {{Pkg|groovy}}, {{AUR|java-gnome}} |
* ビルド: {{ic|groovyc -cp /usr/share/java/gtk.jar HelloWorld.groovy && jar cfe HelloWorld.jar HelloWorld HelloWorld.class}} |
* ビルド: {{ic|groovyc -cp /usr/share/java/gtk.jar HelloWorld.groovy && jar cfe HelloWorld.jar HelloWorld HelloWorld.class}} |
||
* 実行: {{ic|java -cp /usr/share/groovy/embeddable/groovy-all.jar:/usr/share/java/gtk.jar:HelloWorld.jar HelloWorld}} (または {{ic|groovy -cp /usr/share/java/gtk.jar HelloWorld.groovy}}) |
* 実行: {{ic|java -cp /usr/share/groovy/embeddable/groovy-all.jar:/usr/share/java/gtk.jar:HelloWorld.jar HelloWorld}} (または {{ic|groovy -cp /usr/share/java/gtk.jar HelloWorld.groovy}}) |
||
| 186行目: | 210行目: | ||
def Hello = new Notification("Hello world!", "This is an example notification.", "dialog-information") |
def Hello = new Notification("Hello world!", "This is an example notification.", "dialog-information") |
||
Hello.show() |
Hello.show() |
||
| + | }} |
||
| + | |||
| + | '''Haskell''' |
||
| + | |||
| + | * ビルドするのに必要なパッケージ: {{Pkg|haskell-fdo-notify}} |
||
| + | * ビルド: {{ic|ghc hello_world}} |
||
| + | {{hc|hello_world.hs|2= |
||
| + | import DBus.Notify |
||
| + | main = do |
||
| + | client <- connectSession |
||
| + | let hello = blankNote { summary="Hello world!", |
||
| + | body=(Just $ Text "This is an example notification."), |
||
| + | appImage=(Just $ Icon "dialog-information") } |
||
| + | notification <- notify client hello |
||
| + | return 0 |
||
| + | }} |
||
| + | |||
| + | '''IronPython''' |
||
| + | |||
| + | * 依存パッケージ: {{Pkg|notify-sharp-3}}, {{Pkg|ironpython}} |
||
| + | * 実行: {{ic|ipy hello_world.py}} |
||
| + | |||
| + | {{hc|hello_world.py|2= |
||
| + | import clr |
||
| + | clr.AddReference('notify-sharp') |
||
| + | import Notifications |
||
| + | Hello = Notifications.Notification() |
||
| + | Hello.Summary = "Hello world!" |
||
| + | Hello.Body = "This is an example notification." |
||
| + | Hello.IconName = "dialog-information" |
||
| + | Hello.Show() |
||
}} |
}} |
||
'''Java''' |
'''Java''' |
||
| − | * 依存パッケージ: |
+ | * 依存パッケージ: {{AUR|java-gnome}} |
* ビルドするのに必要なパッケージ: java-environment |
* ビルドするのに必要なパッケージ: java-environment |
||
* ビルド: {{ic|javac -cp /usr/share/java/gtk.jar HelloWorld.java && jar cfe HelloWorld.jar HelloWorld HelloWorld.class}} |
* ビルド: {{ic|javac -cp /usr/share/java/gtk.jar HelloWorld.java && jar cfe HelloWorld.jar HelloWorld HelloWorld.class}} |
||
| 213行目: | 268行目: | ||
'''JavaScript''' |
'''JavaScript''' |
||
| − | * 依存パッケージ: {{Pkg|libnotify}}, {{Pkg|gjs}} |
+ | * 依存パッケージ: {{Pkg|libnotify}}, {{Pkg|gjs}} |
{{hc|hello_world.js|2= |
{{hc|hello_world.js|2= |
||
| − | #!/usr/bin/gjs |
||
#!/usr/bin/gjs |
#!/usr/bin/gjs |
||
const Notify = imports.gi.Notify; |
const Notify = imports.gi.Notify; |
||
| 224行目: | 278行目: | ||
"icon-name": "dialog-information"}); |
"icon-name": "dialog-information"}); |
||
Hello.show (); |
Hello.show (); |
||
| + | }} |
||
| + | |||
| + | '''JRuby''' |
||
| + | |||
| + | * 依存パッケージ: {{AUR|java-gnome}}, {{Pkg|jruby}} |
||
| + | * ビルド: {{ic|jrubyc hello_world.rb && jar cfe hello_world.jar hello_world hello_world.class}} |
||
| + | * 実行: {{ic|java -cp /opt/jruby/lib/jruby.jar:hello_world.jar hello_world}} または {{ic|jruby hello_world.rb}} |
||
| + | {{hc|hello_world.rb|2= |
||
| + | require '/usr/share/java/gtk.jar' |
||
| + | import Java::OrgGnomeGtk::Gtk |
||
| + | import Java::OrgGnomeNotify::Notify |
||
| + | import Java::OrgGnomeNotify::Notification |
||
| + | |||
| + | Gtk.init(nil) |
||
| + | Notify.init("Hello world") |
||
| + | Hello = Notification.new("Hello world!", "This is an example notification.", "dialog-information") |
||
| + | Hello.show |
||
| + | }} |
||
| + | |||
| + | '''Jython''' |
||
| + | |||
| + | * 依存パッケージ: {{AUR|java-gnome}}, {{Pkg|jython}} |
||
| + | * 実行: {{ic|1=jython -Dpython.path=/usr/share/java/gtk.jar hello_world.py}} |
||
| + | {{hc|hello_world.py|2= |
||
| + | from org.gnome.gtk import Gtk |
||
| + | from org.gnome.notify import Notify, Notification |
||
| + | Gtk.init(None) |
||
| + | Notify.init("Hello world") |
||
| + | Hello=Notification("Hello world!", "This is an example notification.", "dialog-information") |
||
| + | Hello.show() |
||
}} |
}} |
||
| 237行目: | 321行目: | ||
Hello=Notify.Notification.new("Hello world","This is an example notification.","dialog-information") |
Hello=Notify.Notification.new("Hello world","This is an example notification.","dialog-information") |
||
Hello:show()</nowiki>}} |
Hello:show()</nowiki>}} |
||
| + | |||
| + | '''Nemerle''' |
||
| + | |||
| + | * 依存パッケージ: {{Pkg|notify-sharp-3}} |
||
| + | * ビルドするのに必要なパッケージ: {{AUR|nemerle}} |
||
| + | * ビルド: {{ic|ncc -pkg:notify-sharp-3.0 -out:hello_world.exe hello_world.n}} |
||
| + | * 実行: {{ic|mono hello_world.exe}} |
||
| + | |||
| + | {{hc|hello_world.n|2= |
||
| + | using Notifications; |
||
| + | public class HelloWorld { |
||
| + | static Main() : void { |
||
| + | def Hello = Notification(); |
||
| + | Hello.Summary = "Hello world!"; |
||
| + | Hello.Body = "This is an example notification."; |
||
| + | Hello.IconName = "dialog-information"; |
||
| + | Hello.Show(); |
||
| + | } |
||
| + | } |
||
| + | }} |
||
| + | |||
| + | '''Pascal''' |
||
| + | |||
| + | * 依存パッケージ: {{Pkg|libnotify}} |
||
| + | * ビルドするのに必要なパッケージ: {{Pkg|fpc}}, [https://github.com/ik5/libnotify-fpc libnotify バインディング] |
||
| + | * ビルド: {{ic|fpc hello_world}} |
||
| + | |||
| + | {{hc|hello_world.pas|2= |
||
| + | program hello_world; |
||
| + | uses libnotify; |
||
| + | var hello : PNotifyNotification; |
||
| + | begin |
||
| + | notify_init(argv[0]); |
||
| + | hello := notify_notification_new ('Hello world', 'This is an example notification.', 'dialog-information'); |
||
| + | notify_notification_show (hello, nil); |
||
| + | end. |
||
| + | }} |
||
'''Perl''' |
'''Perl''' |
||
| − | * 依存パッケージ: {{Pkg|libnotify}}, |
+ | * 依存パッケージ: {{Pkg|libnotify}}, {{AUR|perl-glib-object-introspection}} |
{{hc|hello_world.pl|2= |
{{hc|hello_world.pl|2= |
||
#!/usr/bin/perl |
#!/usr/bin/perl |
||
| 259行目: | 380行目: | ||
{{hc|hello_world.py|2= |
{{hc|hello_world.py|2= |
||
#!/usr/bin/python |
#!/usr/bin/python |
||
| + | import gi |
||
| + | gi.require_version('Notify', '0.7') |
||
from gi.repository import Notify |
from gi.repository import Notify |
||
Notify.init ("Hello world") |
Notify.init ("Hello world") |
||
| 267行目: | 390行目: | ||
'''Ruby''' |
'''Ruby''' |
||
| − | *依存パッケージ: {{Pkg|libnotify}}, |
+ | *依存パッケージ: {{Pkg|libnotify}}, {{AUR|ruby-gir_ffi}} |
{{hc|hello_world.rb|2= |
{{hc|hello_world.rb|2= |
||
| 276行目: | 399行目: | ||
Hello = Notify::Notification.new("Hello world!", "This is an example notification.", "dialog-information") |
Hello = Notify::Notification.new("Hello world!", "This is an example notification.", "dialog-information") |
||
Hello.show |
Hello.show |
||
| + | }} |
||
| + | |||
| + | '''Rust''' |
||
| + | |||
| + | [https://crates.io/crates/notify-rust notify-rust] を使用。 |
||
| + | * ビルドするのに必要なパッケージ: {{Pkg|cargo}} |
||
| + | * ビルド: {{ic|cargo build}} |
||
| + | * 実行: {{ic|target/debug/hello_world}} または {{ic|cargo run}} |
||
| + | |||
| + | {{hc|Cargo.toml|2= |
||
| + | [package] |
||
| + | name = "hello_world" |
||
| + | version = "0.1.0" |
||
| + | |||
| + | [dependencies] |
||
| + | notify-rust = "^3" |
||
| + | }} |
||
| + | |||
| + | {{hc|src/main.rs|2= |
||
| + | extern crate notify_rust; |
||
| + | use notify_rust::Notification; |
||
| + | fn main(){ |
||
| + | Notification::new() |
||
| + | .summary("Hello world") |
||
| + | .body("This is an example notification.") |
||
| + | .icon("dialog-information") |
||
| + | .show().unwrap(); |
||
| + | } |
||
}} |
}} |
||
'''Scala''' |
'''Scala''' |
||
| − | * 依存パッケージ: |
+ | * 依存パッケージ: {{AUR|java-gnome}} (と {{Pkg|scala}}) |
* ビルドするのに必要なパッケージ: {{Pkg|scala}} |
* ビルドするのに必要なパッケージ: {{Pkg|scala}} |
||
* ビルド: {{ic|scalac -cp /usr/share/java/gtk.jar -d HelloWorld.jar HelloWorld.scala}} |
* ビルド: {{ic|scalac -cp /usr/share/java/gtk.jar -d HelloWorld.jar HelloWorld.scala}} |
||
| 310行目: | 461行目: | ||
static void main () { |
static void main () { |
||
Notify.init ("Hello world"); |
Notify.init ("Hello world"); |
||
| − | var Hello = new Notification("Hello world!", "This is an example notification.", "dialog-information"); |
+ | var Hello = new Notify.Notification("Hello world!", "This is an example notification.", "dialog-information"); |
Hello.show (); |
Hello.show (); |
||
} |
} |
||
2016年8月19日 (金) 00:04時点における版
関連記事
デスクトップ通知は、非同期に特定のイベントをユーザーに通知する小さくて控えめなポップアップダイアログです。
Libnotify
Libnotify は GTK+ や Qt アプリケーションのサポートを提供する Desktop Notifications Specification の実装で特定のデスクトップに依存していません: Evolution や Pidgin など多数のオープンソースアプリによって使用されています。Libnotify は公式リポジトリにある libnotify パッケージでインストールすることが可能です。
libnotify を使うには、通知サーバーをインストールする必要があります。
通知サーバー
ビルトイン
以下のデスクトップ環境では通知を表示するためにそれぞれ独自の実装を使っており、置き換えることができません。通知サーバーはログイン時に自動で起動し DBus によってアプリケーションからの通知を受け取ります。
- Cinnamon は通知サーバーを備えており、通知は画面の右上に表示されます。
- Enlightenment は Notification 拡張を通して通知サーバーを提供しています。通知オプションは設定が可能です。
- GNOME は通知サーバーを備えており、通知は画面の上部に表示されます。
- KDE は通知サーバーを備えており、通知は画面の右下に表示されます。
スタンドアロン
他のデスクトップ環境では、ウィンドウマネージャやデスクトップ環境の自動実行を使って通知サーバーを起動する必要があります (DBus で初めて呼ばれた時に通知サーバーを起動させることもできますが、グローバルな設定が必要です)。
通知サーバーは以下から選ぶことができます:
- Avant Window Navigator — AWN で使うことができる通知デーモンアプレット。
- Deepin Notifications — Deepin の通知サーバー。
- Dunst — dwm などのミニマルなウィンドウマネージャにうってつけの Linux 用の最小通知デーモン。
- LXQt Notification Daemon — LXQt の通知サーバー。
- Notification Daemon — GNOME Flashback によって使われている通知サーバー。
- https://github.com/GNOME/notification-daemon || notification-daemon
/usr/lib/notification-daemon-1.0/notification-daemonで手動で起動できます。
- MATE Notification Daemon — MATE の通知サーバー。
- https://github.com/mate-desktop/mate-notification-daemon/ || GTK+ 2: mate-notification-daemon, GTK+ 3: mate-notification-daemon-gtk3
- Notify OSD — Unity の通知サーバー。
- statnot — 小さくて軽量な通知デーモン。ルートウィンドウのタイトルや標準出力、FIFO パイプなどに通知を出力できるので、タイル型ウィンドウマネージャと相性がとても良いです。
- twmn — タイル型ウィンドウマネージャ向けの通知システム。
- Xfce Notification Daemon — Xfce の通知サーバー。
プログラミングでの使い方
GObject-Introspection やバインディングを通して多くのプログラミング言語を使ったり、または bash を利用して簡単に libnotify でメッセージを表示することができます。
以下の例ではシンプルな "Hello world" の通知が表示されます。
Bash
- 依存パッケージ: libnotify
hello_world.sh
#!/bin/bash notify-send 'Hello world!' 'This is an example notification.' --icon=dialog-information
Boo
- 依存パッケージ: notify-sharp-3 (boo)
- ビルドするのに必要なパッケージ: boo
- ビルド:
booc hello_world.boo - 実行:
mono hello_world.exe(またはbooi hello_world.boo)
hello_world.boo
import Notifications from "notify-sharp" Hello = Notification() Hello.Summary = "Hello world!" Hello.Body = "This is an example notification." Hello.IconName = "dialog-information" Hello.Show()
C
- 依存パッケージ: libnotify
- ビルド:
gcc -o hello_world `pkg-config --cflags --libs libnotify` hello_world.c
hello_world.c
#include <libnotify/notify.h>
int main() {
notify_init ("Hello world!");
NotifyNotification * Hello = notify_notification_new ("Hello world", "This is an example notification.", "dialog-information");
notify_notification_show (Hello, NULL);
g_object_unref(G_OBJECT(Hello));
notify_uninit();
return 0;
}
C++
- 依存パッケージ: libnotifymmAUR
- ビルド:
g++ -o hello_world `pkg-config --cflags --libs libnotifymm-1.0` hello_world.cc
hello_world.cc
#include <libnotifymm.h>
int main(int argc, char *argv[]) {
Notify::init("Hello world!");
Notify::Notification Hello("Hello world", "This is an example notification.", "dialog-information");
Hello.show();
return 0;
}
C#
- 依存パッケージ: notify-sharp-3
- ビルド:
mcs -pkg:notify-sharp-3.0 hello_world.cs - 実行:
mono hello_world.exe
hello_world.cs
using Notifications;
public class HelloWorld {
static void Main() {
var Hello = new Notification();
Hello.Summary = "Hello world!";
Hello.Body = "This is an example notification.";
Hello.IconName = "dialog-information";
Hello.Show();
}
}
Cobra
- 依存パッケージ: notify-sharp-3
- ビルドするのに必要なパッケージ: cobraAUR
- ビルド:
cobra -c hello_world - 実行:
mono hello_world.exe
hello_world.cobra
@args -pkg:notify-sharp-3.0
use Notifications
class HelloWorld
def main
hello = Notification()
hello.summary = "Hello world!"
hello.body = "This is an example notification."
hello.iconName = "dialog-information"
hello.show
F#
- 依存パッケージ: notify-sharp-3
- ビルドするのに必要なパッケージ: fsharpAUR
- ビルド:
fsharpc -r:notify-sharp.dll -I:/usr/lib/mono/notify-sharp-3.0/ -I:/usr/lib/mono/gtk-sharp-3.0/ hello_world.fs - 実行:
mono hello_world.exe
hello_world.fs
open Notifications let Hello = new Notification() Hello.Summary <- "Hello world!" Hello.Body <- "This is an example notification." Hello.IconName <- "dialog-information" Hello.Show()
Genie
hello_world.gs
uses
Notify
init
Notify.init ("Hello world")
var Hello=new Notify.Notification ("Hello world!","This is an example notification.","dialog-information")
Hello.show ()
Go
- 依存パッケージ: libnotify
- ビルドするのに必要なパッケージ: go-notify-gitAUR
- ビルド:
go build hello_world.go - 実行:
go run hello_world.go
hello_world.go
package main
import ("github.com/mqu/go-notify")
func main() {
notify.Init("Hello world")
hello := notify.NotificationNew("Hello World!", "This is an example notification.","dialog-information")
hello.Show()
}
Groovy
- 依存パッケージ: groovy, java-gnomeAUR
- ビルド:
groovyc -cp /usr/share/java/gtk.jar HelloWorld.groovy && jar cfe HelloWorld.jar HelloWorld HelloWorld.class - 実行:
java -cp /usr/share/groovy/embeddable/groovy-all.jar:/usr/share/java/gtk.jar:HelloWorld.jar HelloWorld(またはgroovy -cp /usr/share/java/gtk.jar HelloWorld.groovy)
HelloWorld.groovy
import org.gnome.gtk.*
import org.gnome.notify.*
Gtk.init()
Notify.init("Hello world")
def Hello = new Notification("Hello world!", "This is an example notification.", "dialog-information")
Hello.show()
Haskell
- ビルドするのに必要なパッケージ: haskell-fdo-notify
- ビルド:
ghc hello_world
hello_world.hs
import DBus.Notify
main = do
client <- connectSession
let hello = blankNote { summary="Hello world!",
body=(Just $ Text "This is an example notification."),
appImage=(Just $ Icon "dialog-information") }
notification <- notify client hello
return 0
IronPython
- 依存パッケージ: notify-sharp-3, ironpython
- 実行:
ipy hello_world.py
hello_world.py
import clr
clr.AddReference('notify-sharp')
import Notifications
Hello = Notifications.Notification()
Hello.Summary = "Hello world!"
Hello.Body = "This is an example notification."
Hello.IconName = "dialog-information"
Hello.Show()
Java
- 依存パッケージ: java-gnomeAUR
- ビルドするのに必要なパッケージ: java-environment
- ビルド:
javac -cp /usr/share/java/gtk.jar HelloWorld.java && jar cfe HelloWorld.jar HelloWorld HelloWorld.class - 実行:
java -cp /usr/share/java/gtk.jar:HelloWorld.jar HelloWorld
HelloWorld.java
import org.gnome.gtk.Gtk;
import org.gnome.notify.Notify;
import org.gnome.notify.Notification;
public class HelloWorld
{
public static void main(String[] args) {
Gtk.init(args);
Notify.init("Hello world");
Notification Hello = new Notification("Hello world!", "This is an example notification.", "dialog-information");
Hello.show();
}
}
JavaScript
hello_world.js
#!/usr/bin/gjs
const Notify = imports.gi.Notify;
Notify.init ("Hello world");
var Hello=new Notify.Notification ({summary: "Hello world!",
body: "This is an example notification.",
"icon-name": "dialog-information"});
Hello.show ();
JRuby
- 依存パッケージ: java-gnomeAUR, jruby
- ビルド:
jrubyc hello_world.rb && jar cfe hello_world.jar hello_world hello_world.class - 実行:
java -cp /opt/jruby/lib/jruby.jar:hello_world.jar hello_worldまたはjruby hello_world.rb
hello_world.rb
require '/usr/share/java/gtk.jar'
import Java::OrgGnomeGtk::Gtk
import Java::OrgGnomeNotify::Notify
import Java::OrgGnomeNotify::Notification
Gtk.init(nil)
Notify.init("Hello world")
Hello = Notification.new("Hello world!", "This is an example notification.", "dialog-information")
Hello.show
Jython
- 依存パッケージ: java-gnomeAUR, jython
- 実行:
jython -Dpython.path=/usr/share/java/gtk.jar hello_world.py
hello_world.py
from org.gnome.gtk import Gtk
from org.gnome.notify import Notify, Notification
Gtk.init(None)
Notify.init("Hello world")
Hello=Notification("Hello world!", "This is an example notification.", "dialog-information")
Hello.show()
Lua
hello_world.lua
#!/usr/bin/lua
lgi = require 'lgi'
Notify = lgi.require('Notify')
Notify.init("Hello world")
Hello=Notify.Notification.new("Hello world","This is an example notification.","dialog-information")
Hello:show()</nowiki>
Nemerle
- 依存パッケージ: notify-sharp-3
- ビルドするのに必要なパッケージ: nemerleAUR
- ビルド:
ncc -pkg:notify-sharp-3.0 -out:hello_world.exe hello_world.n - 実行:
mono hello_world.exe
hello_world.n
using Notifications;
public class HelloWorld {
static Main() : void {
def Hello = Notification();
Hello.Summary = "Hello world!";
Hello.Body = "This is an example notification.";
Hello.IconName = "dialog-information";
Hello.Show();
}
}
Pascal
- 依存パッケージ: libnotify
- ビルドするのに必要なパッケージ: fpc, libnotify バインディング
- ビルド:
fpc hello_world
hello_world.pas
program hello_world;
uses libnotify;
var hello : PNotifyNotification;
begin
notify_init(argv[0]);
hello := notify_notification_new ('Hello world', 'This is an example notification.', 'dialog-information');
notify_notification_show (hello, nil);
end.
Perl
- 依存パッケージ: libnotify, perl-glib-object-introspectionAUR
hello_world.pl
#!/usr/bin/perl
use Glib::Object::Introspection;
Glib::Object::Introspection->setup (
basename => 'Notify',
version => '0.7',
package => 'Notify');
Notify->init;
my $hello = Notify::Notification->new("Hello world!", "This is an example notification.", "dialog-information");
$hello->show;
Python
- 依存パッケージ: libnotify, python-gobject (または Python 2 なら python2-gobject)
hello_world.py
#!/usr/bin/python
import gi
gi.require_version('Notify', '0.7')
from gi.repository import Notify
Notify.init ("Hello world")
Hello=Notify.Notification.new ("Hello world","This is an example notification.","dialog-information")
Hello.show ()
Ruby
- 依存パッケージ: libnotify, ruby-gir_ffiAUR
hello_world.rb
#!/usr/bin/ruby
require 'gir_ffi'
GirFFI.setup :Notify
Notify.init("Hello world")
Hello = Notify::Notification.new("Hello world!", "This is an example notification.", "dialog-information")
Hello.show
Rust
notify-rust を使用。
- ビルドするのに必要なパッケージ: cargo
- ビルド:
cargo build - 実行:
target/debug/hello_worldまたはcargo run
Cargo.toml
[package] name = "hello_world" version = "0.1.0" [dependencies] notify-rust = "^3"
src/main.rs
extern crate notify_rust;
use notify_rust::Notification;
fn main(){
Notification::new()
.summary("Hello world")
.body("This is an example notification.")
.icon("dialog-information")
.show().unwrap();
}
Scala
- 依存パッケージ: java-gnomeAUR (と scala)
- ビルドするのに必要なパッケージ: scala
- ビルド:
scalac -cp /usr/share/java/gtk.jar -d HelloWorld.jar HelloWorld.scala - 実行:
java -cp /usr/share/java/gtk.jar:HelloWorld.jar HelloWorld(またはscala -cp /usr/share/java/gtk.jar HelloWorld.scala)
HelloWorld.scala
import org.gnome.gtk._
import org.gnome.notify._
object HelloWorld {
def main(args: Array[String]) {
Gtk.init(args)
Notify.init("Hello world")
var Hello = new Notification("Hello world!", "This is an example notification.", "dialog-information")
Hello.show()
}
}
Vala
hello_world.vala
using Notify;
public class HelloWorld {
static void main () {
Notify.init ("Hello world");
var Hello = new Notify.Notification("Hello world!", "This is an example notification.", "dialog-information");
Hello.show ();
}
}
Visual Basic .NET
- 依存パッケージ: notify-sharp-3
- ビルドするのに必要なパッケージ: mono-basic
- ビルド:
vbnc -r:/usr/lib/mono/notify-sharp-3.0/notify-sharp.dll hello_world.vb - 実行:
mono hello_world.exe
hello_world.vb
Imports Notifications Public Class Hello Public Shared Sub Main Dim Hello As New Notification Hello.Summary = "Hello world!" Hello.Body = "This is an example notification." Hello.IconName = "dialog-information" Hello.Show End Sub End Class
参照
- Libnotify リファレンスマニュアル
- C サンプル
- Python サンプル (フランス語の記事)