Debian – Start notification-daemon as a service

debiannotifications

I am running Debian and wish to make use of notify-send. But notify-send doesn't give me any notification unless I have one of the following running:

# either:
/usr/lib/notification-daemon/notification-daemon
# or:
/usr/lib/notify-osd/notify-osd

I'd like to run one of these as a service, rather than letting them be jobs in my shell. However, when I create a startup script for them in /etc/init.d (using skeleton as a template), trying to start the service results in the following output, and notify-send displays no notifications:

(notification-daemon:14467): Gtk-WARNING **: cannot open display:

Best Answer

The scripts in /etc/init.d control system-wide startup scripts, while you want to start a service for your individual login session. There are ways to do this for all login sessions for all users, but they depend on how your system is set up. Likewise, there are ways to do this for your individual login session, but it depends on what type of session you are using. (E.g., GNOME, XFCE, KDE, fvwm, whatever.)

What you probably want to do is configure your session manager, desktop environment, or window manager to start /usr/lib/notify-osd/notify-osd at startup. For example, I use fvwm via xsession, so I have in my ~/.xsession the following:

#!/bin/sh

# Other programs I need at startup like xscreensaver and urxvtd ...

/usr/lib/notify-osd/notify-osd &

exec fvwm
Related Question