Kopete Now Listening “Plugin”

So, I’ve been ranting about this all time time in the past. Now I found the answer. Since we have dcop super K power, “Now Listening” plugin is is just a shell away ;)

Enough crap, try this script:
#!/bin/sh
STATUS="(`uptime | awk '{print \$1}'` up) `dcop amarok player nowPlaying`"
dcop kopete KopeteIface setAway "$STATUS"
echo "Kopete Status: $STATUS"

I put that into a ./kopete-status.sh, give chmod u+x, and then do watch -n 5 ./kopete-status.sh.
Voila, I have Kopete Listening to Amarok “Plugin”!

34 Responses to “Kopete Now Listening “Plugin””

  1. Mark says:

    Tight, now if only gaim had a dcop interface….

  2. toni says:

    Yeah, I wish so :) . But I guess, I could be patient enough to wait Kopete to be more stable :D .

  3. K says:

    instead of doing “watch -n 5 ./kopete-status.sh”, you could use KCron :)

  4. toni says:

    Can I? Yay!

    WEll, maybe I’ll use it, after I reworked the script so it won’t annoy our current chat buddy for it’s aupdating our status into something else in 5 secs interval. Need to wait until song got changed before updating Kopete status :)

  5. Bona says:

    Now if we only could change the display name instead of away message.. ’cause I don’t want my status to be ‘away’ all the time :)

  6. toni says:

    Yeah, that’s pretty lame since we are not actually away..

  7. Bona says:

    In KDE 3.5 (beta) it’s now possible to show a “personal message”, if the protocol supports this. MSN and Jabber do.

    So a small tweak to your script:
    “dcop kopete KopeteIface setAway “$STATUS” 0

    I use this with XMMS Song Change plugin. Amarok crashes way to often with my SUSE 9.1. :(

  8. toni says:

    Wow, you’ve tasted KDE 3.5 (Beta)? That’s soo nice. I wonder when I can taste it as well.

    Err, I wonder what is that 0 after $STATUS for? New interface on 3.5?

    I left xmms because I love the way amarok manages our music library. But somehow, I missed the old playlist style .. dunno sure why? :p

  9. pushkar says:

    Hi toni,
    Neat. Indeed.

    I was trodding hoplessly thru all the plugins on offer….but no luck :(

    Your post appeared in the Google search as an angel :)

    And yes Bona… ’cause I don’t want my status to be ‘away’ all the time. Me too.

  10. toni says:

    @pushkar: Angel eh? I’m glad to hear that. Your comment is the best thing ever happen to me today

  11. Palantir says:

    Yes, but if kopete is offline, this script will make it connect… which is something I absoultely don’t want to!
    Isn’t there a dcop call to get the online status, so that if it is offline the script would just exit? I have searched with kdcop but it seems that there is no such an option…

  12. toni says:

    @Palantir
    Wow, I never know that behaviour. I see. I better take a look at the script again. Thanks for your informative comment :)

  13. rorio says:

    Cool!
    If only I could set that not as “away”…

  14. Bona says:

    The 0 (zero) after DCOP call makes the status “Online” in KDE 3.5.

    After the official release of KDE 3.5 Amarok has became more stable and I’m using it again. And there’s plugin called Now Listening built in Kopete. Does the same trick as your script.

    I just wish the plugin would read the cover image of the song playing in Amarok and put it to my picture in Kopete. This does the trick with Kopete “global image”, but it doesn’t seem to change the picture of MSN protocol :(

    PICTURE=`dcop amarok player coverImage`
    dcop kopete KopeteIface setGlobalPhoto “$PICTURE”

  15. Bona says:

    Ah. I take my words back. That changes the picture in MSN, too. :P

  16. toni says:

    Wow, new tricks eh .. Thanks. I’ll try it :)

  17. Gustavo Felisberto says:

    I’m using kde 3.5 on gentoo.
    In kopete i added a identity and choosed that the image would be used by all acounts.
    using:

    PICTURE=`dcop amarok player coverImage`

    echo $PICTURE
    /mnt/external/humpback/mp3/Moonspell/[1995] Wolfheart/folder.jpg

    file “$PICTURE”
    /mnt/external/humpback/mp3/Moonspell/[1995] Wolfheart/folder.jpg: JPEG image data, JFIF standard 1.02

    dcop kopete KopeteIface setGlobalPhoto “$PICTURE” 0
    arguments do not match

    dcop kopete KopeteIface setGlobalPhoto “$PICTURE”
    with no 0 it works but:

    If i’m connected with chat windows open it will lock kopete
    If i run it with kopete running and before connecting it will lock as soon as i send a message.

  18. toni says:

    Could it be a bug?

  19. Gustavo Felisberto says:

    I talked with some of kopete’s dev’s the problem is probably due to the way that kopete handles avatars. If the images are too big it hurt kopete.

    So i did a small script that uses convert (from imagemagick)

    http://www.felisberto.net/~humpback/changepic.sh

    Due to the fact that it will ALWAYS resize the image it is probably not a good idea to have it running every 5 secs. I’m working in a version that will store the image it grabs from amarok. Just w8 a couple of hours.

  20. Gustavo Felisberto says:

    Well it was faster :)

    The script at the url can be run in the background, as it will sleep and check for the changes. As i start kde via .xsession or .xinitrc it is just a matter of adding:

    /home/yourlogin/bin/changepic.sh &

    BEFORE startkde.

    Notes: Dont forget to make the script executable (chmod +x) and i dont know what will happen if kopete/amarok are not running. As far as i can tell it will just try and sleep every 10 seconds.

  21. toni says:

    Wow, you’re fast … interesting .. what I was looking for in the first time was a proper hook to exec the nowlistening “plugin”. wath -n 5 is indeed a cheap shot :p.

    Maybe we can do something bout it, just like what I did with my stdgenplugin for winamp (put wiamp song tittle into yahoo status). We will still use the 5 secs interva, but we’ll add a checking to observe wether there’s actually a song change. This way we don’t have to dcop and hurt Kopete every five secs. For the cover image, the checking will be used against album name. I think checking album name is so mch cheaper that checking the actual pic with rotation method :) . Or we may use the cover image filename itself.

    Okay, we can do that I guess. But I need to take a shower first :D .. Thanks for the script by the way :)

  22. Pembo13 says:

    It would be nice if the script only changed the “Personal Message” of MSN and didn’t change my status.

  23. toni says:

    I’m afraid it’s quite hard to achive. Kopete doesn’t expose anything protocol spesific apparently. This is a cost for universal control over Kopete IM. CMIIW

  24. JAnt says:

    Hi,
    I’m trying to use this script in Kubuntu 5.10.
    When I check the script Output Log I get this:

    —————————————–
    ../scripts/kopete-now-listening/getcfg.sh: line 4: config.conf: File or directory doesn’t exist../scripts/kopete-now-listening/getcfg.sh: line 4: config.conf: File or directory doesn’t exist/home/jant/.kde/share/apps/amarok/scripts/kopete-now-listening/kopete-now-listening.sh: line 27: Amarok: command not foundarguments do not matchno such function/home/jant/.kde/share/apps/amarok/scripts/kopete-now-listening/kopete-now-listening.sh: line 33: Kopete: command not found
    —————————————–
    The directories and scripts are correctly located…any help?

    Thanks in advance!!

  25. toni says:

    JAnt:
    well, that’s pretty weird. There should be no problem when the scripts are already well located. Generally, I only need to install the cript via Script Manager and voila! It runs flawlessly. Could it be Kubuntu spesific problem?

    There are some weird info thought. Like: Amarok command not found. Hmm, there are no direct call to amarok, I suppose. The only thing exist is dcop amarok nowPlaying.

    Any clues, anyone?

  26. JAnt says:

    Thanks for your answer…
    Anyone with Kubuntu 5.10?
    Should I post this question also in http://www.kde-apps.org/content/show.php?content=33503 just in case?

  27. toni says:

    JAnt:
    Sure, maybe we’ll have more clues from anyone monitoring the kde-apps item :) .

  28. alvonsius says:

    JAnt:
    Humm anybody said Kubuntu??? Hehehe, I get the same message from the log, but the application still running well … so I don’t give a damn about it :p

    It might be Kubuntu specific problems … i hope …

  29. toni says:

    Just to make sure that things are working as intended, you may check your kopete avatar after changing a different album on amarok. pay attetion to the song title as well, for it will change your Kopete away status.

    Actually, I’ve updated the script. I ‘ve made an option so we can choose only to set teh away message or only set the album cover, or both. This was caused by the built-in Now Listening plugin within Kopete 0.12. I should really upload it sometime :D

  30. [...] August 15th, 2006 Remember my previous kopete-now-listening script for Amarok? Today, Bartek Celary sends me an email. This is how it goes: Hi, Just to let you know — few fixes to the script. I ripped out the config thing as it was not working in my case and put everything in functions rather that separate file. maybe you would like to have a look and use something of it (i.e. the kopete running test was not working OK for example). cheers, – B. Celary [...]