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:
# or:

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:


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:


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

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

exec fvwm
  • Note that debian Jessie will switch to systemd, so sysv-related advice will largely no longer be up-to-date. – HalosGhost Oct 7 '14 at 14:46

'cannot open display' means that your binary requiers X server which is not running. You have to amend your startscript so that notify-send starts after X server. Post your script if you have issues with that.


To add to @elb's answer:

When I added the line to ~/.xsession it broke the autologin of the machine to the point where logging in became impossible (I guess because the .xsession file was continuously being read each time I logged in?)

Instead I put the same contents in an ~/.xsessionrc file, which did not previously exist on my system. But it did the trick!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.