Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora Resources > Guides & Solutions (No Questions)
FedoraForum Search

Forgot Password? Join Us!

Guides & Solutions (No Questions) Post your guides here (No links to Blogs accepted). You can also append your comments/questions to a guide, but don't start a new thread to ask a question. Use another forum for that.

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 25th January 2010, 08:38 PM
Jamwa Offline
Registered User
 
Join Date: Jan 2008
Location: Nairobi Kenya
Posts: 558
linuxfedorafirefox
Amarok Now Playing

Having been frustrated by the existing now-playing scripts, I wrote this one for myself. Tested on Amarok 2.2 and Kopete 0.80., feel free to extend it to Pidgin (note attached, I dont use pidgin so I cannot test it yet).

A downloadable tar installer script is also available.

Code:
#!/bin/bash
#===================================================================================
#
#         FILE: amarok_now_playing
#
#        USAGE: amarok_now_playing [ > logfile]
#
# DESCRIPTION: Changes your status message in pidgin and/or
#               Kopete to the song you are currently listening to in Amarok.
#
#      OPTIONS: see function ’usage’ below
# REQUIREMENTS: --- Amarok 2.2, Kopete 0.70
#         LICENCE: GNU GPL
#        NOTES: ---
#       AUTHOR: Arthur Buliva, arthurbuliva [at] fedoraproject [dot] org
#      COMPANY: Arthur Buliva
#      VERSION: 1.0
#      CREATED: 26.05.2009 - 16:17:51
#     REVISION: 16.10.2009 - 12:32:36
#===================================================================================

STARTUP="qdbus org.kde.amarok / Identity"
ALLOWED_AMAROK_VERSION="2.2"
ALLOWED_KOPETE_VERSION="0.80"
PIDGIN="`kopete --version`"

#Messages to display if Amarok is not playing any song

MESSAGES=(
"Quiet",
"Amarok is Quiet",
"Long live KDE"
)

#Test for Amarok
echo -n "Checking Amarok version... "
a=`$STARTUP | cut -c 8-`
if [[ "$a" =~ "${ALLOWED_AMAROK_VERSION}" ]]
then
    echo "Amarok $a [ OK ] "
else
    echo -n $a;tput setaf 1;tput bold;echo -n "     [ FAILED ] ";tput sgr0;echo "Make sure that you are running Amarok 1.4 | `date +%b-%d-%Y\ %T` ";
    logger "$0 failed to start. Detected Amarok $a but requires Amarok $ALLOWED_AMAROK_VERSION"
    exit;
fi


#Test for Kopete
echo -n "Checking Kopete version... "
if [[ "$PIDGIN" =~ "${ALLOWED_KOPETE_VERSION}" ]]
then
    echo "Kopete $PIDGIN [ OK ] "
else
  echo -n $a;tput setaf 1;tput bold;echo -ne "\nERROR: ";tput sgr0;echo "This script has been tested on Kopete 0.70 only | `date +%b-%d-%Y\ %T` "
  logger "$0 failed to start. Detected Kopete $PIDGIN but requires Kopete 0.70"
  exit
fi

updateStatus()
{

    if [[ "`$STARTUP`" != "" ]]
    then

    SONG_TITLE="qdbus org.kde.amarok /Player GetMetadata"
    ARTIST="qdbus org.kde.amarok /Player GetMetadata"

    KOPETE_STATUS='qdbus org.kde.kopete /Kopete'
    
    if [[ "`$KOPETE_STATUS`" == "" ]]
    then
	tput setaf 1;tput bold;echo -n "ERROR: ";tput sgr0;echo "Kopete is not running. This script will terminate | `date +%b-%d-%Y\ %T` "
	logger "$0 terminated because Kopete is not running"
	exit
    fi

    if [[ "`$SONG_TITLE  | grep title: | cut -c 8-`" != "" ]]
    then
	TITLE="♫ `$SONG_TITLE  | grep title: | cut -c 8-` by `$ARTIST  | grep artist: | cut -c 9- `";
	logger "$TITLE";
	echo $TITLE;
	#Pidgin
	#`/usr/bin/purple-remote "setstatus?status=available&message=$TITLE"`
	#Kopete
	qdbus org.kde.kopete /Kopete  org.kde.Kopete.setIdentityOnlineStatus "Online" "$TITLE"
	sleep 10;
	updateStatus
    else
	
	TITLE=${MESSAGES[ $[ ( $RANDOM % 1 )  + 1 ] - 1  ])};
	echo $TITLE;
	#Pidgin
	#`/usr/bin/purple-remote "setstatus?status=available&message=$TITLE"`
	#Kopete
	qdbus org.kde.kopete /Kopete  org.kde.Kopete.setIdentityOnlineStatus "Online" "$TITLE"
	sleep 30;
	updateStatus
    fi

    else
	tput setaf 1;tput bold;echo -n "ERROR: ";tput sgr0;echo "Could not connect to DCOP Server | `date +%b-%d-%Y` "
	logger "$0 Could not connect to DCOP Server"
	exit
    fi
}

updateStatus
Reply With Quote
 

Tags
amarok, playing

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Amarok not playing after yum update Jamwa Using Fedora 2 30th December 2009 06:26 PM
amarok mp3 playing problem Yentor Using Fedora 7 5th August 2009 08:18 PM
Amarok on Fedora 10 not playing any song manuleka Using Fedora 6 26th May 2009 02:27 PM
problem with amarok playing mp3 mohan.10 Using Fedora 4 8th October 2008 09:48 PM
kaffeine, amarok not playing in FC8 shreedhan Using Fedora 5 30th November 2007 04:25 PM


Current GMT-time: 03:09 (Wednesday, 22-10-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat
Famagusta Travel Photos - West Gulfport - Khosta Photos on Instagram