This is about XMMS, a great mediaplayer, and an improvement of it's interaction with KDE and it's filemanager Konqueror.
I'm a gentoo user and the following observations may not be true for users of other linuxes/unices.
The default behavior is as follows:
  • Clicking on an audio file in Konqueror removes the current file in the playlist.
  • By allowing multiple instances of XMMS, which is nice to switch between playlists on the fly, every clicking produces a new instance.
The goal is:
  • Opening a file in via Konqueror should enqueue the file in XMMS.
  • Multiple instances are allowed.
That's all. Pretty easy, hu?
The key to achieve this is little script that takes advantage of two particluar command line parameters of XMMS. Namely these parameters are:
-e, --enqueue       Don't clear the playlist.
-n, --session       Select XMMS session (Default: 0).
Using these two together like this:
xmms -e -n 0 some_file
enqueues some_file to the playlist of the first XMMS instance.
But what if there is no instance of xmms? Everybody would expect the start of a new xmms instance. But instead nothing happens.
So, we have to start our first instance manually, or by a little script. This little script looks like this:
echo $#
if [ $# -ne 0 ]
  sessions=`ps | grep ' xmms$'`
  echo $sessions
  if [ "$sessions" = "" ]
    xmms &

while [ $# -ne 0 ]
  xmms -e -n 0 "$1"
First it checks whether there are any files to open. If this is the case, the "ps | grep" figures out, whether or not an instance is already up. If not, an initial instance is started. And then all files are simply enqueued.
The Space and $ in the grep command make sure not to accept anything with xmms as a part of it's name as xmms itself. For example, this script is called myxmms.sh on my computer. A simple "grep xmms" would always lead to a hit, which is not desired.
No it's time to register this script as a handler for the right files. Under KDE this is done by the controlcenter. I registered it as the default for mp3 and mpegurl (this is m3u). Make sure to deactivate the start notification. This is activated by default and leads to many hopping icons whenn clicking on mp3 files.
That's all. Thank you for your patience :)