Skip to content
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 · 9 comments
Closed

fail to start dunst via systemd and service #347

jduf opened this issue Aug 1, 2017 · 9 comments

Comments

@jduf
Copy link

@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
Copy link
Member

@bebehei 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
Copy link
Member

@tsipinakis 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
Copy link
Member

@bebehei bebehei commented Aug 1, 2017

Related commit: 52b08e4

@jduf
Copy link
Author

@jduf 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
Copy link
Member

@tsipinakis 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
Copy link
Author

@jduf 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
Copy link
Member

@tsipinakis 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
Copy link
Contributor

@WhyNotHugo 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
See [fail to start dunst via systemd and service · Issue #347 ·
dunst-project/dunst](dunst-project/dunst#347)
fmarier added a commit to fmarier/user-scripts that referenced this issue Sep 27, 2019
@ericfreese
Copy link
Contributor

@ericfreese ericfreese commented Feb 18, 2020

This might not be relevant to many folks, but I was struggling with this for a while and found that I had a script (50-systemd-user.sh) in /etc/X11/xinit/xinitrc.d/ that wasn't being called by anything. When initially setting up my ~/.xinitrc file, I had removed the final if block that runs every script in that dir. Adding it back in fixed the issue. Check the default xinitrc file at /etc/X11/xinit/xinitrc, and see the note here:

Note: At the very least, ensure that the last if block in /etc/X11/xinit/xinitrc is present in your ~/.xinitrc file to ensure that the scripts in /etc/X11/xinit/xinitrc.d are sourced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants