#!/bin/bash
# Adium theme AdiumMessageStyle installer for Empathy
# Originally © 2009 Antono Vasiljev
# Licensed under the same terms as Empathy
# http://antono.info/en/165-install-adium-themes-to-empathy
# Changed by Vertlo Oraerk (did not work with directories containing spaces in the names)
# Changed by h!v from ubuntuforums to work with Pidgin+libwebkit and Notifications
# On Ubuntu you need to install libwebkit and libnotify-bin to get it working properly
# Further info on how to get working adium themes in Pidgin at http://www.webupd8.org/2009/05/pidgin-webkit-plugin-adium-conversation.html
# 02-12-2010 - Support for Adium 1.0 sound themes added. Hooha!
# Sound themes are supported in 2.6.x versions. If there's no file set for event, Pidgin falls to default sound file.
# IM
#Message Sent = send_im
#Message Received (New) = first_im_recv
#Message Received = im_recv
# Chat
#Message Sent = send_chat_msg - you send a message in a chat
#Message Received (Group Chat) = chat_msg_recv - someone else sends a message in a chat
#You Are Mentioned = nick_said - someone says your username in a chat
# Status
#Contact Signed On = login
#Contact Signed Off = logoff
#Contact Joins = join_chat - a person enters a chat
#Contact Leaves = left_chat - a person leaves a chat
types[0]="Message Sent"
types[1]="Message Received (New)"
types[2]="Message Received"
types[3]="Message Sent"
types[4]="Message Received (Group Chat)"
types[5]="You Are Mentioned"
types[6]="Contact Signed On"
types[7]="Contact Signed Off"
types[8]="Contact Joins"
types[9]="Contact Leaves"
events[0]="im_sent"
events[1]="first_im_recv"
events[2]="im_recv"
events[3]="send_chat_msg"
events[4]="chat_msg_rec"
events[5]="nick_said"
events[6]="login"
events[7]="logoff"
events[8]="join_chat"
events[9]="left_chat"
# Creating a file
if [ -z $1 ]
then
echo
echo "Usage:"
echo "`basename $0` adiumxtra://some.url.here/extra"
echo
exit 1
else
TMPDIR=`mktemp -d`
XTRAURL=`echo $1 | sed -e "s/^adiumxtra:/http:/"`
DEST="$HOME/.purple/message_styles/"
if [ ! -d $DEST ]
then
mkdir -v -p $DEST
fi
cd $TMPDIR
notify-send "File this" \ "for Adium to be seems" --icon=pidgin
wget --no-verbose -O xtra.zip $XTRAURL
unzip -qq xtra.zip
ls -d ./*.AdiumMessageStyle/ > themes_to_copy.lst
ls -d ./*.AdiumSoundset/ > sound.lst
num_bytes=`wc -c themes_to_copy.lst | sed 's# themes_to_copy.lst##'`
sound=`wc -c sound.lst | sed 's# sound.lst##'`
NAME=`cat themes_to_copy.lst | cut -f 2 --delimiter='.' | cut -f 2 --delimiter='/'`
NAME_S=`cat sound.lst | cut -f 2 --delimiter='.' | cut -f 2 --delimiter='/'`
if [ $num_bytes = 0 ]
then
if [ $sound = 0 ]
then
notify-send "All here I found" \ "gibberish was" --icon=pidgin
else
while read line_
do
if [ ! -d $line_/Sounds.plist ]
then
notify-send "Found I theme" \ " $NAME_S " --icon=pidgin
DEST="$HOME/.purple/themes/$NAME_S/purple/sound/"
if [ ! -d $DEST ]
then
mkdir -v -p $DEST
fi
# Creating a file
touch theme.xml
echo -e " ">> $line_/theme.xml
echo -e "" >> $line_/theme.xml
while read line
do
if [ "$line" = "Info" ]
then
read line
inf=`echo $line | sed -e "s///" | sed -e "s/<\/string>//"`
echo -e "\t$inf" >> $line_/theme.xml
fi
for ((j=0; j<=9; j++))
do
if [ "$line" = "${types[j]}" ]
then
read line
file=`echo $line | sed -e "s///" | sed -e "s/<\/string>//"`
echo -e "\t" >> $line_/theme.xml
fi
done
done < $line_/Sounds.plist
echo -e "" >> $line_/theme.xml
echo cp -r \'$line_\'* $DEST | sh
else
notify-send "Use I force could" \ "none effect, that made" --icon=pidgin
fi
done < sound.lst
fi
else
while read line
do
echo cp -r \'$line\' "$DEST" | sh
done < themes_to_copy.lst
echo
notify-send "Installed I" \ " $NAME for you " --icon=pidgin
fi
rm -r xtra.zip
rm -r $TMPDIR
fi
exit 0