All pastes #986094 Raw Edit

Mine

public text v1 · immutable
·published 2008-04-15 15:07 UTC
rendered paste body
#!/bin/bash
#Filename: gaim-status
#Version: 1.2.4
#License: GPL version 2
#Code by AppleGrew
#Based on code from http://gentoo-wiki.com/TIP_Gaim_Autoprofile_plugin.

sleep_time=90 #Adjust the timer to suit your likings.
#Setting it to too lower value will consume CPU cycles
#and the script may also exit if Gaim fails to load in the above time.

if [[ $1 == "startgaim" ]] || [[ $2 == "startgaim" ]]
then
	#Checking if gaim is allive or not.
	if `pgrep -x gaim >/dev/null`
	then
		echo "Gaim already running, continuing to load gaim-status..."
	else
		gaim &
	fi
fi

#Checking if the script is already running or not. If yes then exitting.
gaimstatus_proc_count=`pgrep -c gaim-status`
if [ $gaimstatus_proc_count -ge 2 ]
then
	echo "Only one instance of the script can run at a time."
	exit 1
fi

skip=0
while [[ 1 == 1 ]]
do	
	player_title=""
	isVideo=0
	player_artist=""
	player_song=""
	#Checking if Amarok is allive and kicking or not.
	if `dcop | grep amarok >/dev/null` && [[ `dcop amarok player isPlaying` == "true" ]]
	then
		player_artist=`dcop amarok player artist`
		player_song=`dcop amarok player title`
	fi
	
	#Checking if Kaffeine is allive and kicking or not.
	if `dcop | grep kaffeine >/dev/null` && [[ `dcop kaffeine KaffeineIface isPlaying` == "true" ]]
	then
		if [[ `dcop kaffeine KaffeineIface isVideo` == "true" ]]
		then
			player_title=`dcop kaffeine KaffeineIface title`
			isVideo=1
		else
			player_artist=`dcop kaffeine KaffeineIface artist`
			player_song=`dcop kaffeine KaffeineIface title`
		fi
	fi
	
	if [[ $isVideo == 0 ]]
	then
		if [[ $player_artist == "" ]] && [[ $player_song == "" ]]
		then
			player_title=""
		else
			player_title="$player_artist- $player_song"
		fi
	fi
	if [[ "$player_title" != "" ]]
	then
		if [[ $isVideo == 1 ]]
		then
			msg="⚇♪ $player_title"
		else
			msg="♫ $player_title"
		fi
	fi
	
	if [[ "$player_title" == "" ]]
	then
		if [[ $1 != "nofortune" ]]  && [[ $2 != "nofortune" ]]
		then
			if [[ $skip == 1 ]]
			then
				skip=2
			else
				# Displaying random messages.
				msg=`fortune -ue|cat`
				msg=`echo -en "Auto Message (Ignore if offensive): \n$msg"`
				skip=1
				#Comment out the line above if you donot want fortune
				#messages to change at twice the period of song messages.
			fi
		else
			msg=""
		fi
	else
		skip=0
	fi
	if [[ $skip != 2 ]]
	then
		gaim-remote "setstatus?status=available&message=$msg"
	else
		skip=0
	fi
	sleep "${sleep_time}s"

	#Checking if gaim is allive or not.
	if ! `pgrep -x gaim >/dev/null`
	then
		exit 0
	fi
done