Closed zachfeldman closed 1 year ago
Could you show your systemd unit file? Not sure exactly how systemd does things but I suspect x11 is not the way here.
Sure @diwic , good point, maybe I don't really want to access DBus through X11 in a systemd
service, that might be more appropriate for something run under my windowed session...heres my unit file:
[Unit]
Description=This program monitors dbus for messages and makes a connected USB device react to them
[Service]
ExecStart=/usr/bin/my-outputted-bin
[Install]
WantedBy=multi-user.target
it is pretty simple.
So; this looks like a system service rather than a session service, right? Can you double check that you're connecting to the system bus and not the session bus? You will not have a session bus in multi-user.target
.
Thanks for pointing me in the right direction @diwic ! I actually did mean to make a session service but I wasn't as familiar with systemd
s options for setting one up. I've familiarized myself and all is working as expected now. Super appreciate you!
When I try to run this example from this package https://github.com/diwic/dbus-rs/blob/366a6dca3d20745f5dcfa006b1b1311c376d420e/dbus/examples/monitor.rs with
cargo run
everything works great!When I
cargo build
though and try to run as asystemd
service, I get this error:Using X11 for dbus-daemon autolaunch was disabled at compile time, set your DBUS_SESSION_BUS_ADDRESS instead (org.freedesktop.DBus.Error.NotSupported)'
Ok, fair enough. But how can I compile
libdbus-sys
with this feature enabled? I tried turning on thevendored
feature in both this crate and the one explicitly inCargo.toml
but it gave me the same error. MyCargo.toml
:If that's impossible for some reason, I've also tried setting DBUS_SESSION_BUS_ADDRESS to
unix:path=/run/user/1000/bus
after runningexport DBUS_SESSION_BUS_ADDRESS=$(grep -P -o -a "(?<=DBUS_SESSION_BUS_ADDRESS=).+?(?=\x00)" /proc/"$(pgrep gnome-session | head -1)"/environ)
following some advice from this SO thread https://stackoverflow.com/questions/41242460/how-to-export-dbus-session-bus-address. I got this error:D-Bus connection failed: D-Bus error: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken. (org.freedesktop.DBus.Error.NoReply)'
I also tried setting DBUS_SESSION_BUS_ADDRESS to
unix:path=/run/dbus/system_bus_socket
, which the program seemed to accept, but which didn't seem to accept any messages or show them as my experiments withcargo run
did.If anyone knows how I can just ensure that
libdbus-sys
just compiles with this option on, that would be great, as all of my use cases are in X11 environments. Thanks for your help!