websocketd
websocketd copied to clipboard
bash script running on websocketd can't connect to dbus
In my bash script i called a command fcitx5-remote for switching input method, the command needs connect to dbus for calling fcitx5 interface. Then when i run this script in websocketd services, it's reporting error 'what(): Failed to create dbus connection' in log. When printing dbus environment variables in the script, it's all empty.
So is there a solution make enable commands running on websocketd could connect to dbus.
You say "environment variable sin the script, it's all empty". Have you looked at the --passenv option?
I know nothing about dbus, but many things get confused if their expected environment variables are absent.
--passenv does not work for CGI scripts (for websocket processes it works as expected). This appears to be unintentional, as the code to make it work is written except only missing this trivial fix: https://github.com/matvore/websocketd/commit/cd87527f0ebcb98a1833bec4e762ea4e534f2a08
Thanks to @PerMildner , after --passenv DBUS_SESSION_BUS_ADDRESS,XDG_RUNTIME_DIR, it's working fine.