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”!

  • Mark

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

  • http://neofreko.com toni

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

  • K

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

  • http://neofreko.com toni

    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 :)

  • Bona

    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 :)

  • http://neofreko.com toni

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

  • Bona

    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. :(

  • http://neofreko.com toni

    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

  • pushkar

    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.

  • http://neofreko.com toni

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

  • http://www.netpalantir.it Palantir

    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…

  • http://neofreko.com toni

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

  • rorio

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

  • Bona

    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”

  • Bona

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

  • http://neofreko.com toni

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

  • Gustavo Felisberto

    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.

  • http://neofreko.com toni

    Could it be a bug?

  • Gustavo Felisberto

    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.

  • Gustavo Felisberto

    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.

  • http://neofreko.com toni

    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 :)

  • http://neofreko.com toni
  • http://www.pembo13.com Pembo13

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

  • http://neofreko.com toni

    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

  • JAnt

    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!!

  • http://neofreko.com toni

    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?

  • JAnt

    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?

  • http://neofreko.com toni

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

  • http://alvonsius.blogsome.com alvonsius

    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 …

  • http://neofreko.com toni

    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

  • http://neofreko.com toni
  • Pingback: Geek Building The Bridge Part 2 » Blog Archive » Briefer kopete-now-listening script

  • http://FavScripts.com Malise

    aaah, is there an update to this?