Difference between revisions of "Desktop notifications"

From ArchWiki
Jump to: navigation, search
(Write your own notify app: Add Perl example)
(Write your own notify app: Add Ruby example)
Line 124: Line 124:
 
Hello.show ()
 
Hello.show ()
 
pynotify.uninit ()</nowiki>}}
 
pynotify.uninit ()</nowiki>}}
 +
 +
 +
====Ruby====
 +
*Dependency: {{AUR|ruby-libnotify}} from AUR
 +
{{File|hello_world.py|<nowiki>#!/usr/bin/ruby
 +
require 'RNotify'
 +
Notify.init("Hello world")
 +
Hello = Notify::Notification.new("Hello world", "This is an example notification.", "dialog-information")
 +
Hello.show
 +
Notify.uninit</nowiki>}}
  
 
====Vala====
 
====Vala====

Revision as of 08:52, 29 October 2011

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 – فارسی

Libnotify is an easy way to display desktop notifications and information in a small dialog. It's used in much open source apps like Evolution, Pidgin, etc. It has support for Gtk+ and Qt applications and is desktop independent.

Installation

The libnotify package is available from the Extra repository. Install libnotify from a terminal with the following command. Template:Cli

Note: Usually you don't have to install libnotify explicitly, since all applications that requires libnotify depends on it.

In order to use libnotify in desktop environments, you have to install a notification server:

GNOME

  • gnome-shell provides a notification server itself. Notifications are displayed at the bottom of the screen.
  • In GNOME Fallback mode, you need to install notification-daemon:
Template:Cli
Note: notification-daemon is a required component for GNOME Fallback mode. You can't login without it.

KDE

KDE uses knotify4 from kdebase-runtime package to display notifications. If you are using KDE, this package is already installed.

XFCE

To get notifications in XFCE, you need to install xfce4-notifyd: Template:Cli

Tip: To configure xfce4-notifyd, run the following command in the terminal: Template:Codeline.

Unity

Unity uses Notify OSD, which is available in AUR: notify-osdAUR.

Other DEs

Other DEs could use notification-daemon (should be launched explicitly), xfce4-notifyd or notify-osdAUR (automatically launched by D-Bus on request).

Tips & Tricks

Write your own notify app

You can write your own libnotify display messages easily in many programming languages through GObject-Introspection or bindings, or you can simply use bash.

The following examples display simple a "Hello world" notification.

Bash

Template:File

C

Template:File

C#

Template:File

Genie

Template:File

JavaScript (gjs)

Template:File

JavaScript (seed)

Template:File

Perl

Template:File

Python

Template:File

Python 2 (python-notify)

Template:File


Ruby

Template:File

Vala

Template:File

More Resources