LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   dbus failed to connect to session bus (https://www.linuxquestions.org/questions/slackware-14/dbus-failed-to-connect-to-session-bus-4175707708/)

wlan0 02-08-2022 05:37 PM

dbus failed to connect to session bus
 
Hello,

I am having trouble getting anything that requires dbus to work.

I have the following in my /etc/X11/xinit/xinitrc.dwm file:
Code:

exec dbus-launch --sh-syntax --exit-with-session dwm
And I still cannot launch anything that requires dbus.
When I try to launch something such as mailspring:

Code:

[2 zypak-helper] Failed to connect to session bus: [org.freedesktop.DBus.Error.NotSupported] Using X11 for dbus-daemon autolaunch was disabled at compile time, set your DBUS_SESSION_BUS_ADDRESS instead.
Anything that requires dbus fails.

What am I doing wrong?

mumahendras3 02-08-2022 11:21 PM

Quote:

Originally Posted by wlan0 (Post 6327220)
Hello,

I am having trouble getting anything that requires dbus to work.

I have the following in my /etc/X11/xinit/xinitrc.dwm file:
Code:

exec dbus-launch --sh-syntax --exit-with-session dwm
And I still cannot launch anything that requires dbus.
When I try to launch something such as mailspring:

Code:

[2 zypak-helper] Failed to connect to session bus: [org.freedesktop.DBus.Error.NotSupported] Using X11 for dbus-daemon autolaunch was disabled at compile time, set your DBUS_SESSION_BUS_ADDRESS instead.
Anything that requires dbus fails.

What am I doing wrong?

dbus-launch --sh-syntax will actually print out to stdout the required environment variables that are needed for other programs to find the newly launched dbus-daemon, hence you have to wrap the dbus-launch command with "eval" then exec to dwm.

A simpler way is to just use dbus-run-session like:

Code:

exec dbus-run-session -- dwm
At the end of your xinitrc.dwm.

EDIT:
Upon reading the dbus-launch man page, specifying the program to run as dbus-launch argument should automatically set the environment variables for the program specified as the argument. So I don't know why the DBUS_SESSION_BUS_ADDRESS is not picked up by your programs.

0XBF 02-09-2022 07:24 AM

Quote:

Originally Posted by mumahendras3 (Post 6327293)
EDIT:
Upon reading the dbus-launch man page, specifying the program to run as dbus-launch argument should automatically set the environment variables for the program specified as the argument. So I don't know why the DBUS_SESSION_BUS_ADDRESS is not picked up by your programs.

Yes the program launched by 'dbus-launch' should have the DBUS_SESSION_BUS_ADDRESS environment variable set. The '--sh-syntax' option is useful for setting the DBUS_SESSION_BUS_ADDRESS in the originating script, in case more programs needed to be launched and made aware of a session dbus in the same script.

With the OP using 'exec' to start dwm, setting DBUS_SESSION_BUS_ADDRESS in the xinitrc script wont be used after that line so something else is going on.

Check if the DBUS_SESSION_BUS_ADDRESS environment variable is set prior to launching mailspring. If it is then something is unsetting DBUS_SESSION_BUS_ADDRESS when you start mailspring. I'm also not sure what 'zypak-helper' is. A preliminary search shows its some sort of sandboxing app so maybe that is clearing the DBUS_SESSION_BUS_ADDRESS variable somehow when it starts up?

ernobe 05-19-2022 11:24 AM

According to https://dbus.freedesktop.org/doc/dbus-launch.1.html and https://dbus.freedesktop.org/doc/dbu...session.1.html you should not use dbus-launch to run your program, instead use dbus-run-session.

0XBF 05-19-2022 01:27 PM

Quote:

Originally Posted by ernobe (Post 6354818)
According to https://dbus.freedesktop.org/doc/dbus-launch.1.html and https://dbus.freedesktop.org/doc/dbu...session.1.html you should not use dbus-launch to run your program, instead use dbus-run-session.

I've read those man pages before and didnt see anything about one method being preferred over the other so I'm not sure where you are seeing that. They both have very similar operation but dbus-launch has a few more options, where dbus-run-session is basically the same as 'dbus-launch --exit-with-session' as I understand it.

Either way, slackware uses a mix of dbus-run-session and dbus-launch across the various xinitrc and .desktop files, so we end up having to be familiar with both if you ever get into modifying those files.

ernobe 05-19-2022 02:37 PM

The OP was not asking in this case for what is preferred, but for anything that will work. And of the two, dbus-run-session is the only one that specifically says that it is meant to run a program:

Quote:

dbus-run-session is used to start a session bus instance of dbus-daemon from a shell script, and start a specified program in that session.

0XBF 05-19-2022 04:20 PM

I see what you meant. I thought we were talking about starting a 'dwm' X session, which can be done with either method.

The weird thing with the OP's problem was that the dbus address should have been set in the environment with either method, but the mailspring application claims it was not. Starting mailspring with dbus-run-session and no address set in the environment would just start mailspring in its own isolated session dbus, no? At any rate, I'll leave this thread for now, unless OP updates the situation.

ernobe 05-19-2022 07:55 PM

As I mentioned in a recent post on Reddit, even if DBUS_SESSION_BUS_ADDRESS is set in the environment, dbus-run-session will change it to a unix:abstract one, run your program, then revert it to its previous value when your program exits. My Reddit post is on r/artixlinux, the subreddit of Artix Linux, which removes systemd and related annoyances like dbus. It took me a while to figure out, but as far as I'm concerned, you might as well give up on trying to set your own DBUS_SESSION_BUS_ADDRESS values, it's all been taken care of by dbus-run-session.


All times are GMT -5. The time now is 02:10 PM.