[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Launch an X Windows app from Apache (PHP or Perl)

On Wed, Dec 14, 2005 at 09:49:50PM -0800, elentirmo@gmail.com wrote:
> Hi
> I'm setting up an automated movie player system on my Ubuntu box and
> what I want to be able to do is run an application (totem) when a I
> click a link to a movie on my page. This will be run from the server,
> logged in as my default account (it'll be a home theatre system)
> The php command I'm calling is
> $command=@system("/usr/bin/totem --fullscreen /mnt/hdd1/MOVIE");
> Now because www-data is actually calling this command I get the error
> (totem:9414): Gtk-WARNING **: cannot open display:

The problem here is that totem does not know what X display to connect
to.  That information is contained in the DISPLAY environment variable,
so to hardcode it:

@system("DISPLAY=:0 /usr/bin/totem --fullscreen /mnt/hdd1/MOVIE");

But note, that will work only if totem can authenticate to the server.
That requires an entry in its user's .Xauthority (or XAUTHORITY variable
pointing elsewhere).

You probably want to create an account for the application, have that
account start X with 'startx' and have the script, or at least totem,
run with that account's permissions.  This will ensure that the right
Xauthority file is used and also enforce some security.

Reply to: