So I got DAAP working on Songbird using Firefly (mt-daapd) from home to uni (Thanks to Matt for finding these).
Then I wanted to be able to control Songbird easily so I went about configuring my keyboard shortcuts. I decided that I wanted Songbird to pause when I lock the machine, then automatically play when it is unlocked. There are a few issues with just changing your lock command to a script which does this, notably the fact that xlock is non-blocking due to gnome-screensaver running as a daemon. Also if you use the command line extension to songbird to play/pause it you can end up playing a song when you lock it if it is paused before hand. There is also the issue of opening songbird when it is not running in order to pause it… I overcame these problems with the following (probably not optimised) script. Note, you’ll need to change the location to your location of songbird.
#!/bin/bash
if [ “`ps aux | grep -v grep | grep songbird`” != “” ]
then
/data/private/cxs548/Songbird/songbird -status
if [ “`cat /tmp/Songbird/status.txt`” == “playing” -o “`cat /tmp/Songbird/status.txt`” == “buffering” ]
then
/data/private/cxs548/Songbird/songbird -pause
xlock
while [ “`gnome-screensaver-command -q`” != “The screensaver is inactive” ]; do sleep 1; done
/data/private/cxs548/Songbird/songbird -play
else
xlock
fielse
xlock
fi
For this to work you will need the command line plugin (http://addons.songbirdnest.com/addon/1381) for songbird and my addition to it which creates a status.txt file in the temp directory. I wanted to print it to stdout but printing from an extension will output to stdout of the parent Songbird process which isn’t very useful. My addition should be placed in the services.js file (found at ~/.songbird2/<PROFILE>/extensions/[email protected]/components/service.js) just under all the other “if (cmdLine.handleFlag…)” lines:
if (cmdLine.handleFlag(“status”, false)) {
var file = Components.classes[“@mozilla.org/file/local;1”].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(“/tmp/Songbird/status.txt”);
if (file.exists() == false) {
file.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420);
}
var stream = Components.classes[“@mozilla.org/network/file-output-stream;1”].createInstance(Components.interfaces.nsIFileOutputStream);
stream.init(file, 0x02 | 0x08 | 0x20, 0666, 0);var content;
var status = gMM.status;
switch (status.state) {
case status.STATUS_PLAYING:
content = “playing”;
break;
case status.STATUS_PAUSED:
content = “paused”;
break;
case status.STATUS_STOPPED:
content = “stopped”;
break;
case status.STATUS_BUFFERING:
content = “buffering”;
break;
default:
content = “unknown”;
break;
}
stream.write(content, content.length);
stream.close();
cmdLine.preventDefault = true;
}