views:

45

answers:

1

I have Rhythmbox running on my desktop, and I want to be able to control it from remotely via a web interface. I'm having problems accessing it, however, because rhythmbox-client is complaining that the user (www-data) that is trying to access it doesn't a) have as X session running, and b) doesn't have access to my rhythmbox dbus information.

(rhythmbox-client:13954): Rhythmbox-WARNING **: /bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed.

I'm running apache, php on ubuntu 10.04. The following methods have also been tried by calling the php script via php cli from a different user (sshing into my own box with a different user)

I've tried these approaches:

  • calling system() and exec() from the php script with "rhythmbox-client --print-playing --no-start --no-resent"
  • using DBus directly in php as well as a python script (calling it from the php script with system()/exec())
  • using setuid(), setruid(), seteuid() in a C program and calling it via php.

I'm at a loss now. Is this even possible?

[EDIT] I have used @IvanGoneKrazy's suggestion and taken the environ code from this similar question. Now I have this code with this error message:

import subprocess, os

p = subprocess.Popen('dbus-launch', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for var in p.stdout:
  sp = var.split('=', 1)
  os.environ[sp[0]] = sp[1][:-1]

os.system('rhythmbox-client --print-playing')

error message:

(rhythmbox-client:15377): Rhythmbox-WARNING **: Launch helper exited with unknown return code 1
A: 

A similar problem and Python solution for is given here. The root issue seems to be that system() and exec() do not have the correct environment variables set. You can use PHPs http://us.php.net/manual/en/function.proc-open.php to set the environment vars for your PHP spawned process.

IvanGoneKrazy