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:


4 Answers 4


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
    Commented Oct 7, 2014 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!


Add the following systemd unit file:

# ~/.config/systemd/user/notification-daemon.service
Description=Notification Daemon



Note that display-manager.service might be different on your system, the trick is to make it After something that starts the X server.

As your user, run

systemctl --user enable --now notification-daemon.service

The --now is optional, it's just like doing start at the same time.

  • 1
    Also see this for how to autostart the notification server lazily, using D-Bus.
    – Maëlan
    Commented Aug 27, 2019 at 22:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .