Skip to content

Instantly share code, notes, and snippets.

@tremby
Created January 6, 2012 18:03
Show Gist options
  • Save tremby/1571679 to your computer and use it in GitHub Desktop.
Save tremby/1571679 to your computer and use it in GitHub Desktop.
im -- change Pidgin status
#!/bin/bash
purple-remote getstatus &>/dev/null
if [ $? -ne 0 ]; then
exit 1
fi
# get old status and message
if [ -f $HOME/.imstatus ]; then
previousstatus=$(head -n 1 $HOME/.imstatus)
previousmessage=$(tail -n 1 $HOME/.imstatus)
else
previousstatus="available"
previousmessage=""
fi
# store current status and message
purple-remote getstatus getstatusmessage >$HOME/.imstatus
# set new status and message
case "$1" in
restore|back)
status="$previousstatus"
message="$previousmessage"
rm $HOME/.imstatus
;;
""|available)
status="available"
message=""
rm $HOME/.imstatus
;;
lunch|luncheon)
status="away"
message="luncheon"
;;
gym|gymnasium)
status="away"
message="gymnasium"
;;
away|afk)
status="away"
message=""
;;
*)
if [ "$2" = "available" ]; then
status="available"
elif [ "$2" = "" -o "$2" = "away" ]; then
status="away"
else
status="$2"
fi
echo "gonna set status to $status"
message="$1"
;;
esac
purple-remote "setstatus?status=$status&message=$message"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment