tags:

views:

53

answers:

2

Hello, 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 DBUS 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
+1  A: 

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
Dennis Williamson
Hm, I moved it to the /tmp/.Xdbus and now there aren't any errors but status doesn't change.
Ockonal
@Ockonal: Apparently it's now working? What else did you do to fix it?
Dennis Williamson
+1  A: 

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

Aif
with $PWD/.Xdbus it says that file doesn't exist. But with /tmp/.Xdbus there aren't errors. But status is the same.
Ockonal
depends from where you run the script. If possible, prefer an absolute path.
Aif
Script is in /bin/script.sh with need rights `-rwxr--r-- 1 root root `
Ockonal
Hm, now it won't work even If I run it from console from default user. It worked before. So strange.
Ockonal