sobota, 27. junij 2009

controlling the totem player via d-bus

Lately I've switched from mplayer to the Totem player, for a better GUI and spiffier handling of much-used MP4 videos. The next thing I wanted was a web remote so that I could control the player via my iPod touch'es browser. I Googled a bit, found nothing to my taste and then wrote this:


It's a php remote, which uses ssh to control Totem and fetch playlist data. For instance, when I click on a file in my media library, this gets issued:

system("ssh ike@chii 'DISPLAY=:0.0 totem --replace \"/path/to/media/file\" 2>&1'");

or for sending the computer to sleep,

system("ssh ike@chii sudo /usr/sbin/pm-suspend");

Apart from that, I doesn't do much, but it's kind-of all I need to enjoy tv from my bed.

The dependencies on this baby are, however, quite big:
- http server (nginx);system("ssh ike@chii 'DISPLAY=:0.0 totem --replace \"/path/to/media/file\" 2>&1'");
- php5 fastcgi processes;
- ssh public key setup, whereupon the server process (www-data) can access my user account without use of the password.

I wanted to boil this down to a standalone python webserver, which I would simply run as a non-root user and let that be that. Also, instead using the totem command to control another totem instance, I wanted to use the d-bus protocol. IPC would be what the big boys use, anyway.

As it turns out, d-bus is very poorly supported. Totem does use it to receive media keys from the Gnome Settings Daemon (GSD) on the session bus, but won't want to receive from anything else. I've went to great lengths to replicate the d-bus signal GSD sends to Totem, using both the dbus-send shell utility and my own C code (http://pastie.org/526510), but it would not nudge. As far as I can tell, this isn't possible without modification of totem source code itself.

What is did essentially boils down to:
- used dbus-monitor to inspect the communication between GSD and Totem
- tried replicating it with dbus-send
- when that failed, wrote a C program which called the "SendMediaKeys" operation on the same interface CSD does. Sent it to the totem proxy iself, and to all (null destination = bus-wide broadcast); neither did stick

I'll write up on that as soon as I know more.

ponedeljek, 23. februar 2009

Firefox is already running but not responding

It's an old issue (several years, at least), but it still happens. Ocasionally, the Mozilla Firefox browser will fail to start, citing the error: "Firefox is already running but not responding". 

Other instances of the browser may of may not be running.

What you do, is pop up a terminal window, and type the following:


$ killall firefox$ rm -fr $HOME/.mozilla/firefox/*default/.parentlock

After the .parentlock lock file is gone, firefox should start as normal.

On shared machines with many novice users, I'd put the following in $HOME/.bashrc:

alias firefox='rm -fr $HOME/.mozilla/firefox/*default/.parentlock; firefox'
That way, everytime you run firefox, the lock gets deleted first. In my experience, there aren't any noticable side effects. But do drop me a comment if you find any.