I'm using accessing thorough DBUS from some process. The trouble is that it runs from another user and session of DBUS is different for them. So I can't acces application which uses DBUS through another process if the sessions are different. I found the way to resolve this trouble: some script writes into file dbus session data from main user (I set it at system loading). Here is that script:
#!/bin/bash
touch /.Xdbus
chmod 666 /.Xdbus
env | grep DBUS_SESSION_BUS_ADDRESS > /.Xdbus
echo 'export DBUS_SESSION_BUS_ADDRESS' >> /.Xdbus
Here is an example of that file:
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-9yStbCgjwb,guid=0deadb6519676638e1e93f5000000023
export DBUS_SESSION_BUS_ADDRESS
Now I just have to execute data from that file and both DBUS sessions will be same. Here is some troubles:
#!/bin/bash
if [ -f /.Xdbus ]
then
source /.Xdbus; /usr/bin/purple-remote "setstatus?status=away&message=At lunch"
else
echo "File doesnt exist"
fi
As you could see, I'm using pidgin as D开发者_开发问答BUS application. But it throws the error, that there is no purple application, so the DBUS sessions are different! So comand:
source /.Xdbus
Didn't work. Why?
UPD
source /.Xdbus; echo $DBUS_SESSION_BUS_ADDRESS; /usr/bin/purple-remote "setstatus?status=away&message=At lunch"; echo $DBUS_SESSION_BUS_ADDRESS;
→
unix:abstract=/tmp/dbus-9yStbCgjwb,guid=0deadb6519676638e1e93f5000000023 No existing libpurple instance detected. unix:abstract=/tmp/dbus-9yStbCgjwb,guid=0deadb6519676638e1e93f5000000023
Based on your update, the source
command is working. Therefore the problem is with purple-remote
or libpurple
or some dependency rather than with your Bash script.
It's not a good idea to create such files in the root directory. Try choosing a more appropriate location for your file. One of the following perhaps:
/home/username/.Xdbus
/var/local/.Xdbus
- you might have to add your user to the group that owns this directory/tmp/.Xdbus
I think it is because you use / which is the root of the filesystem. What you want is ./ or an absolute path as said Dennis.
You can also use $PWD/file or ${pwd}/file
精彩评论