Skip to main content
Topic: D-Bus user service with Turnstile (Read 760 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

D-Bus user service with Turnstile

I'm having a bit of trouble figuring out how to sort out a user service for D-Bus when using Turnstile. I've been aware for a long while that Turnstile is meant to handle exporting DBUS_SESSION_BUS_ADDRESS to the login environment, but I'm not sure that this is working right or I simply have no idea how to properly export it to the activation environment.

Currently, I'm having to effectively re-define and export the variable in the service's script as follows:

Code: [Select]
#!/bin/sh
export DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus"
dinitctl setenv DBUS_SESSION_BUS_ADDRESS || :

exec dbus-daemon --session --address="$DBUS_SESSION_BUS_ADDRESS" "$@"

The service itself:

Code: [Select]
type               = process
load-options       = sub-vars
command            = $HOME/.config/dinit.d/scripts/dbus-session --print-address 3
smooth-recovery    = true
ready-notification = pipefd:3

Re: D-Bus user service with Turnstile

Reply #1
Bump. Anyone got a solution?

 

Re: D-Bus user service with Turnstile

Reply #2
I don't use turnstile myself, however it seems that using "dinitctl setenv" in the service file is a preferred method. The docs indicate that turnstile won't handle this part for us.

Quote from: turnstile https://github.com/chimera-linux/turnstile?tab=readme-ov-file#d-bus-session-bus-address
By default, the address of the D-Bus session bus will be exported into the login environment and set to something like unix:path=$XDG_RUNTIME_DIR/bus, if that socket exists and is valid in that path.

This allows the D-Bus session bus to be managed as a user service, to get systemd-style behavior with a single session bus shared between user logins. It can be explicitly disabled if necessary, but mostly there is no need to as the variable will not be exported if the bus does not exist there.

Note that this does not mean the bus address is exported into the activation environment, as turnstile does not know about it. The user service that spawns the session bus needs to take care of that, e.g. with dinitctl setenv for Dinit. Only this way will other user services know about the session bus. [Emphasis added]