Remote control with pidgin/purple

Thu 21 April 2011

I use a script I wrote called 'lockit' to lock my screen (see http://blog.woofbit.com/2010/10/12/locking-your-desktop-elegantly/) and realized I was missing something: Set pidgin/finch back to their original status state once it comes back from AFK. So I modified them soi

# When locking:
if pgrep pidgin &> /dev/null; then
    # Get existing status message
    currentStatusMessage="$(purple-remote 'getstatusmessage')"
    currentStatus="$(purple-remote 'getstatus')"
    # Save it
    echo "STATUS=$currentStatus" > $statusSaveFile
    echo "MESSAGE=$currentStatusMessage" >> $statusSaveFile
    # Set new message
    purple-remote 'setstatus?status=away&message='"$message"
fi

# When unlocking:
if pgrep pidgin &> /dev/null; then
    oldStatus="$(grep '^STATUS=' $statusSaveFile | cut -d= -f2-)"
    oldStatusMessage="$(grep '^MESSAGE=' $statusSaveFile | cut -d= -f2-)"
    purple-remote 'setstatus?status='"$oldStatus"'&message='"$oldStatusMessage"
    rm "$statusSaveFile"
fi

The "getstatus" and "setstatus" commands are just a tiny subset of what you can do with purple-remote. Check out http://developer.pidgin.im/wiki/DbusHowto for ideas!

Category: Linux Tagged: bash linux pidgin purple scripting shell status

comments