websocketd icon indicating copy to clipboard operation
websocketd copied to clipboard

bash script running on websocketd can't connect to dbus

Open baoheping opened this issue 2 years ago • 3 comments

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.

baoheping avatar Feb 19 '23 13:02 baoheping

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.

PerMildner avatar Feb 19 '23 16:02 PerMildner

--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

matvore avatar Feb 19 '23 23:02 matvore

Thanks to @PerMildner , after --passenv DBUS_SESSION_BUS_ADDRESS,XDG_RUNTIME_DIR, it's working fine.

baoheping avatar Mar 05 '23 06:03 baoheping