How to export DBUS_SESSION_BUS_ADDRESS

↘锁芯ラ 提交于 2019-12-31 16:48:46

问题


I'm trying to run D-Bus on an embedded system (Yocto Linux) and connect to it from my application code.

I get the following error when I call dbus_bus_get(DBUS_BUS_SESSION, &err);

Using X11 for dbus-daemon autolaunch was disabled at compile time, set your DBUS_SESSION_BUS_ADDRESS instead

I realize that I need to start the dbus-daemon first so I have run dbus-launch from the command line. This prints out a value of DBUS_SESSION_BUS_ADDRESS but how could I export it programmatically?

Thanks for the help


回答1:


I've finally found the answer, running the following command exports the output of dbus-launch:

export $(dbus-launch)



回答2:


pid_gnome=$(pgrep gnome-session)
DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/${pid_gnome}/environ|cut -d= -f2-)
export DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS}

Please make sure that the user has the DISPLAY variable set.

Another alternative is:

export $(dbus-launch)



回答3:


Type in terminal:

eval \`dbus-launch --auto-syntax`



回答4:


Type in terminal:

export $DBUS_SESSION_BUS_ADDRESS


来源:https://stackoverflow.com/questions/41242460/how-to-export-dbus-session-bus-address

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!