You are not logged in.

#1 2015-09-11 18:33:41

SuperZanti
Member
Registered: 2013-06-18
Posts: 21

[Solved] Dbus service not registered?

I'm having trouble getting notifications as a non-root user to send properly.

I've tried just about everything I know how...

I was hoping to get the dbus service in

/usr/share/dbus-1/services/org.knopwob.dunst.service

working, but it only seems to work as root user. When I do a

notify-send "test"

it does not work, however if I do a

sudo notify-send "test"

it works just fine. I should also mention that this only happens with the dbus service. If I start dunst in a terminal, then everything works as expected. However, I would like it to start up automatically with notify-send as needed.

I have a few things that are doing at notify-send on startup. It seems that the very first notify-send as soon as the x-server and i3 get started works just fine displaying a "Display settings changed" message, but it must crash after that because running a

ps aux | grep dunst

returns nothing. I've been trying to debug this but I'm afraid I've hit a dead end. Even some information on where dunst puts it's error logs might help me.

If I add

dunst &

to my xinitrc then I witness the same behavior, dunst seems to crash after the first message.

Check out more updates here: https://github.com/knopwob/dunst/issues/238

Last edited by SuperZanti (2015-09-12 02:30:11)

Offline

#2 2015-09-11 19:03:33

ooo
Member
Registered: 2013-04-10
Posts: 1,637

Re: [Solved] Dbus service not registered?

did you check journal for any errors. If anything crashes, you should see something there.

Last edited by ooo (2015-09-11 19:03:52)

Offline

#3 2015-09-11 19:10:31

SuperZanti
Member
Registered: 2013-06-18
Posts: 21

Re: [Solved] Dbus service not registered?

I just did. Every time I try to send a notification with notify-send this is what journal pops up with:

Sep 11 13:07:49 Chell dbus-daemon[621]: Activating service name='org.freedesktop.Notifications'
Sep 11 13:07:49 Chell org.freedesktop.Notifications[621]: cannot open display
Sep 11 13:07:49 Chell dbus-daemon[621]: Activated service 'org.freedesktop.Notifications' failed: Process org.freedesktop.Notifications exited with status 1

But it's weird because if I run a sudo notify-send, I get the popup from dunst just fine on the correct display and everything.

Here is the service that it should be calling:

$ cat /usr/share/dbus-1/services/org.freedesktop.Notifications.service 
[D-BUS Service]
Name=org.freedesktop.Notifications
Exec=/usr/bin/dunst

With these messages I was able to come up with a temporary solution. I made a shell script: /usr/bin/dunst.sh

#!/bin/bash

export DISPLAY=:0
/usr/bin/dunst

And this works just fine without any crashes or errors when I change the dbus service file to execute this shell script. But what if my display changes? This doesn't seem like the best solution to me. Why isn't dbus giving the proper display to the dbus service?

Last edited by SuperZanti (2015-09-11 19:38:08)

Offline

#4 2015-09-11 21:48:51

SuperZanti
Member
Registered: 2013-06-18
Posts: 21

Re: [Solved] Dbus service not registered?

I found that if I run

export $(dbus-launch)

everything works as expected.

So why aren't these environment variables being set when I login?

Offline

#5 2015-09-11 22:06:33

ooo
Member
Registered: 2013-04-10
Posts: 1,637

Re: [Solved] Dbus service not registered?

wiki recommends sourcing /etc/X11/xinit/xinitrc.d/30-dbus.sh in .xinitrc, which would export DBUS_SESSION_BUS_ADDRESS

eval $(dbus-launch)

works as well.

Offline

#6 2015-09-11 22:16:29

SuperZanti
Member
Registered: 2013-06-18
Posts: 21

Re: [Solved] Dbus service not registered?

The problem with this is that now I have 2 instances of dbus running.

$ ps aux | grep dbus
dbus       377  0.0  0.0  36952  3920 ?        Ss   16:12   0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
sz       612  0.0  0.0  36684  3708 ?        Ss   16:12   0:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation
sz       617  0.0  0.0  36684  3620 ?        S    16:12   0:00 /usr/bin/dbus-daemon --config-file=/etc/at-spi2/accessibility.conf --nofork --print-address 3
sz       651  0.0  0.0  43964  2120 ?        S    16:12   0:00 dbus-launch --autolaunch=f562fc1e8c60410899d6a7310c056658 --binary-syntax --close-stderr
sz      1294  0.0  0.0  36684   324 ?        Ss   16:16   0:00 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
sz      1339  0.0  0.0  10732  2248 pts/1    S+   16:16   0:00 grep dbus

as you can see there is one with a pid of 1294 and one with a pid of 612

I also don't have a /etc/X11/xinit/xinitrc.d/30-dbus.sh

From what I understand systemd takes care of that now since it's a dependency.

Also even if I use this 30-dbus.sh:

https://gist.github.com/qiukun/4218

I still get the same results.

Last edited by SuperZanti (2015-09-11 22:33:51)

Offline

#7 2015-09-12 00:48:13

ooo
Member
Registered: 2013-04-10
Posts: 1,637

Re: [Solved] Dbus service not registered?

SuperZanti wrote:

The problem with this is that now I have 2 instances of dbus running.

$ ps aux | grep dbus
dbus       377  0.0  0.0  36952  3920 ?        Ss   16:12   0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
sz       612  0.0  0.0  36684  3708 ?        Ss   16:12   0:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation
sz       617  0.0  0.0  36684  3620 ?        S    16:12   0:00 /usr/bin/dbus-daemon --config-file=/etc/at-spi2/accessibility.conf --nofork --print-address 3
sz       651  0.0  0.0  43964  2120 ?        S    16:12   0:00 dbus-launch --autolaunch=f562fc1e8c60410899d6a7310c056658 --binary-syntax --close-stderr
sz      1294  0.0  0.0  36684   324 ?        Ss   16:16   0:00 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
sz      1339  0.0  0.0  10732  2248 pts/1    S+   16:16   0:00 grep dbus

as you can see there is one with a pid of 1294 and one with a pid of 612.

Is that right after fresh logout->login->startx cycle. The other process was apparenly started 4 minutes later, but I can only guess who or what started it.
EDIT: The 612 pid dbus looks like it was started for the systemd user session.

SuperZanti wrote:

I also don't have a /etc/X11/xinit/xinitrc.d/30-dbus.sh.

How did you install dbus, or are you even running arch linux?

$ pacman -Qo /etc/X11/xinit/xinitrc.d/30-dbus.sh
/etc/X11/xinit/xinitrc.d/30-dbus.sh is owned by dbus 1.10.0-2
SuperZanti wrote:

From what I understand systemd takes care of that now since it's a dependency.

You still need to start the dbus session from .xinitrc, unless you're using desktop environment that starts it for you. The systemd dbus session is for systemd services only.
https://wiki.archlinux.org/index.php/Systemd/User#D-Bus
https://wiki.archlinux.org/index.php/D-Bus

SuperZanti wrote:

Also even if I use this 30-dbus.sh:

https://gist.github.com/qiukun/4218

I still get the same results.

That file is different from the one provided by latest dbus package from arch repos, so I'm not that surprised if it didn't work.

Last edited by ooo (2015-09-12 00:54:23)

Offline

#8 2015-09-12 01:02:05

SuperZanti
Member
Registered: 2013-06-18
Posts: 21

Re: [Solved] Dbus service not registered?

Yes, I'm using arch linux. My version of dbus is 1.10.0-3.
My kernel version is 4.2.0-3

Even with a re-install of dbus there is still no 30-dbus.sh

Finally, all the processes started at 16:12 were after I logged into the tty, after I started x, and after i3 had loaded. I then ran dbus-launch and the process at 16:16 showed up.

So from what I understand you're saying it's okay to have 2 dbus processes because systemd needs it's own? What command should I use to start the dbus session in my .xinitrc?

Thanks for all of your help by the way.

Offline

#9 2015-09-12 01:44:28

ooo
Member
Registered: 2013-04-10
Posts: 1,637

Re: [Solved] Dbus service not registered?

SuperZanti wrote:

Yes, I'm using arch linux. My version of dbus is 1.10.0-3.

Okay, so you've enabled [testing] repo. The latest dbus in [core] is 1.10.0-2, and apparently the 30-dbus.sh was removed in pkgrel 3 with some other stuff. Really, if you've enabled [testing], you should be aware when this kind of stuff happens, and mention it when seeking help.

SuperZanti wrote:

So from what I understand you're saying it's okay to have 2 dbus processes because systemd needs it's own?

Afaik, having multiple dbus processes shouldn't hurt anything. My guess is the process 612 on your last post was started by systemd user session, however I don't see such process running on my system, even though the systemd user session is running (I haven't enabled any user services though):

dbus       393  0.0  0.0  37476  3796 ?        Ss   Sep11   0:05 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
dnsmasq    440  0.0  0.0  41768  3068 ?        Ss   Sep11   0:00 /usr/bin/dnsmasq -k --enable-dbus --user=dnsmasq --pid-file
joonas   10151  0.0  0.0  43956  2600 tty1     S    03:04   0:00 dbus-launch --sh-syntax --exit-with-session
joonas   10152  0.0  0.0  36888  2888 ?        Ss   03:04   0:00 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
joonas   10192  0.0  0.0  36676  3424 ?        S    03:04   0:00 /usr/bin/dbus-daemon --config-file=/etc/at-spi2/accessibility.conf --nofork --print-address 3
joonas   21438  0.0  0.0  10736  2172 pts/0    S+   04:21   0:00 grep dbus

In my case dbus is started automatically by gnome.

SuperZanti wrote:

What command should I use to start the dbus session in my .xinitrc?

If you revert back to dbus-1.10.0-2 you could source the 30-dbus.sh, or I'm pretty sure this has worked in my ~/.xinitrc before:

eval $(dbus-launch --sh-syntax --exit-with-session)

Offline

#10 2015-09-12 02:29:32

SuperZanti
Member
Registered: 2013-06-18
Posts: 21

Re: [Solved] Dbus service not registered?

Thanks for your help. I'll just add in something to start it (might revert, we'll see.

With your help I've found a solution.

Marking as solved.

Offline

#11 2015-09-12 11:55:43

ooo
Member
Registered: 2013-04-10
Posts: 1,637

Re: [Solved] Dbus service not registered?

I took a closer look at changes in dbus-1.10.0-3, especially commit labeled "with systemd 226: use dbus user bus".

I think the idea on removing the 30-dbus.sh, is that you wouldn't need to launch dbus via .xinitrc any more, but it would be handled by systemd instead. That would explain why you were seeing two dbus processes while I didn't with dbus-1.10.0-2. At quick glance I couldn't find anything to confirm this from mailing list or testing forum though.

With all due respect, if you've enabled the testing repo, you should be able to figure these things yourself. Especially since (if my theory is correct) the new dbus revision apparently didn't work as expected on your system, and you should've reported it as an arch bug instead of bothering dunst developers.

Nevertheless, I'm happy to hear you got it sorted out :)

Offline

#12 2015-10-04 07:52:19

nbd
Member
Registered: 2014-08-04
Posts: 389

Re: [Solved] Dbus service not registered?

I have the same problem and from the above it's a bit unclear what's the correct way to solve it? I don't have testing repo enabled; in '/etc/X11/xinit/xinitrc.d' directory I have '50-systemd-user.sh' file which has the following:

systemctl --user import-environment DISPLAY XAUTHORITY

if which dbus-update-activation-environment >/dev/null 2>&1; then
        dbus-update-activation-environment DISPLAY XAUTHORITY
fi

In the D-Bus/User wiki it's written that one of the ways of exporting env. variables to dbus applications is:

At any time, use systemctl --user set-environment or systemctl --user import-environment. Affects all user units started after setting the environment variables, but not the units that were already running.

Can the problem be an indication that the service unit (/usr/share/dbus-1/services/org.xfce.xfce4-notifyd.Notifications.service in my case) is started before the '50-systemd-user.sh'?


bing different

Offline

#13 2015-10-04 13:30:25

aminjam
Member
Registered: 2015-10-04
Posts: 1

Re: [Solved] Dbus service not registered?

nbd wrote:

I have the same problem and from the above it's a bit unclear what's the correct way to solve it? I don't have testing repo enabled; in '/etc/X11/xinit/xinitrc.d' directory I have '50-systemd-user.sh' file which has the following:

systemctl --user import-environment DISPLAY XAUTHORITY

if which dbus-update-activation-environment >/dev/null 2>&1; then
        dbus-update-activation-environment DISPLAY XAUTHORITY
fi

In the D-Bus/User wiki it's written that one of the ways of exporting env. variables to dbus applications is:

At any time, use systemctl --user set-environment or systemctl --user import-environment. Affects all user units started after setting the environment variables, but not the units that were already running.

Can the problem be an indication that the service unit (/usr/share/dbus-1/services/org.xfce.xfce4-notifyd.Notifications.service in my case) is started before the '50-systemd-user.sh'?

I am seeing the same thing as yours. Your theory seems correct. After running "/etc/X11/xinit/xinitrc.d/50-systemd-user.sh" I get to see the ouput from "notify-send 'hi'". I wonder if I should now just change the .xinitrc to source the "50-systemd-user.sh". Anyone knows if this is the right direction?

Last edited by aminjam (2015-10-04 13:30:59)

Offline

Board footer

Powered by FluxBB