New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fail to start dunst via systemd and service #347

Closed
jduf opened this Issue Aug 1, 2017 · 8 comments

Comments

Projects
None yet
4 participants
@jduf

jduf commented Aug 1, 2017

I run the latest version of dunst on a debian 9 and I can't start dunst properly. I read your documentation and the make install command correctly sets all the files required to start dunst via systemd. Unfortunately it doesn't work and the command journalctl -b -p 7..0 run as root outputs:

Aug 01 11:52:38 pink-floyd systemd[986]: Starting Dunst notification daemon... 
Aug 01 11:52:38 pink-floyd systemd[986]: Starting Accessibility services bus...
Aug 01 11:52:39 pink-floyd dbus-daemon[1107]: Successfully activated service 'org.a11y.Bus' 
Aug 01 11:52:39 pink-floyd systemd[986]: Started Accessibility services bus.
Aug 01 11:52:39 pink-floyd dunst[1297]: cannot open display
Aug 01 11:52:39 pink-floyd systemd[986]: dunst.service: Main process exited, code=exited, status=1/FAILURE
Aug 01 11:52:39 pink-floyd systemd[986]: Failed to start Dunst notification daemon.
Aug 01 11:52:39 pink-floyd systemd[986]: dunst.service: Unit entered failed state.
Aug 01 11:52:39 pink-floyd systemd[986]: dunst.service: Failed with result 'exit-code'.

then a bit later in the same output

Aug 01 11:58:01 pink-floyd systemd[986]: Starting Dunst notification daemon...
Aug 01 11:58:01 pink-floyd dunst[4114]: cannot open display
Aug 01 11:58:01 pink-floyd systemd[986]: dunst.service: Main process exited, code=exited, status=1/FAILURE
Aug 01 11:58:01 pink-floyd systemd[986]: Failed to start Dunst notification daemon.
Aug 01 11:58:01 pink-floyd systemd[986]: dunst.service: Unit entered failed state.
Aug 01 11:58:01 pink-floyd systemd[986]: dunst.service: Failed with result 'exit-code'.

Thanks for your help

@bebehei

This comment has been minimized.

Member

bebehei commented Aug 1, 2017

Aug 01 11:58:01 pink-floyd dunst[4114]: cannot open display

Obviously, the DISPLAY-variable is not set. Add in your systemd-service file in the Service-Section the line Environment=DISPLAY=:0.

But that's just the quickfix.

@tsipinakis

This comment has been minimized.

Member

tsipinakis commented Aug 1, 2017

As @bebehei said, the most likely cause is that the DISPLAY environment variable is not set within systemd. I just ran a test on a Debian 9 VM with i3, xinit and dbus-user-session installed and the systemd service appears to be working fine.

Can you give some more details on your setup? What desktop environment are you using? How are you starting X?

@bebehei

This comment has been minimized.

Member

bebehei commented Aug 1, 2017

Related commit: 52b08e4

@jduf

This comment has been minimized.

jduf commented Aug 1, 2017

Thanks for your quick response!

I'm using a minimalistic version of debian with dwm for desktop environment. I log on my session via the terminal and then run xinit which executes the ~/.xinitrc containing:

#!/bin/bash
exec dwm
@tsipinakis

This comment has been minimized.

Member

tsipinakis commented Aug 1, 2017

log on my session via the terminal and then run xinit

Ah, there's the problem, xinit is the low level command to initialize X, useful if you want a truly minimal system but it skips the system-wide X initialization which can cause problems. I'd recommend using startx instead if possible.

After some digging, looks like that the relevant scripts to properly link dbus, systemd and X11 apps are 20dbus_xdg-runtime and 95dbus_update-activation-env from the dbus-user-session package.

@jduf

This comment has been minimized.

jduf commented Aug 1, 2017

adding the Environment=DISPLAY=:0 in /usr/local/lib/systemd/user/dunst.service solved the problem.

If you find a "long term solution" to this problem, let me know !

thanks again!

@jduf jduf closed this Aug 1, 2017

@tsipinakis

This comment has been minimized.

Member

tsipinakis commented Aug 1, 2017

Glad that worked, though that file may be overwritten on updates.

Another (possibly better) solution would be to add systemctl --user set-environment DISPLAY=:0 to your xinitrc file. (Untested, though theoretically it should work)

@WhyNotHugo

This comment has been minimized.

Contributor

WhyNotHugo commented Aug 1, 2017

systemctl --user import-environment DISPLAY is probably better, since it'll work with wayland/xwayland and non-default DISPLAYs.

shalomb added a commit to shalomb/dotfiles that referenced this issue Apr 22, 2018

Ensure the DISPLAY environment variable is set
See [fail to start dunst via systemd and service · Issue #347 ·
dunst-project/dunst](dunst-project/dunst#347)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment