May 27, 2008

How-To: Make a Simple Amarok Now Playing Script for Konversation in Bash

Konversation comes with a very good now playing script residing in /usr/share/apps/konversation/scripts/media. It's made in Python and has support for many audio players, among these being Amarok, JuK or XMMS. However, if you only use Amarok and want a real simple now playing script, you can make one in Bash. Just create the file anp.bash in your ~/.kde/share/apps/konversation/scripts/ directory, chmod 755 it and copy the following in it:

#!/bin/bash

PORT=$1;
SERVER=$2;
TARGET=$3;

nowPlaying="$(dcop amarok default nowPlaying)"
out="Rocks! $nowPlaying"

dcop $PORT default say $SERVER "$TARGET" "$out"


Then open Konversation and go to Settings -> Configure Konversation... -> Command Aliases and add anp as the Alias and /exec anp.bash as the Replacement. You can execute it with the command /ANP in any channel or query window. Note that the example is a very basic one, so if Amarok is not running the message which will appear will only be 'Rocks! '.

Updated: Jun 23, 2008 (Created: May 27, 2008)

4 comments:

Anonymous said...

Hi, thanks for your script, do you know how run this automatically? I mean: when song changes in amarok, show it automatically in Konversation channel. thanks in advance.

Craciun Dan said...

Yes. You will have to copy it into ~/.kde/share/apps/konversation/scripts, then use an alias to trigger it. To make an alias open Konversation, go to Settings -> Configure Konversation -> Command Aliases then fill in data there, like anp and /exec anp.

Also, have a look at /usr/share/apps/konversation/scripts, you will see the other default scripts there.

Craciun Dan said...

Now I see I misunderstood your question. I know it's possible, but I've never done it. I think it's done the other way around: make an Amarok script which will dcop konversation when the song changes.

Anonymous said...

Well.. finally i found a solution: make my own script, it's called AmaKonvi. You can find it in KDE-apps, google it :-)