Questo post è più un appunto che un vero HOWTO. Con lo script di cui presento il codice è possibile ottenere degli aggiornamenti mirati del messaggio di stato (e dello stato stesso) in occasione di eventi prestabiliti, ad esempio la riproduzione di un file multimediale. Per accostarvi allo scenario potete pensarlo come una versione un po’ più rozza dei plugin che, in altri programmi di messaggistica istantanea, prelevano il titolo della canzone in riproduzione da un player.
L’utilizzo di uno script esterno permette ad applicazioni che non dispongono naturalmente di una tale capacità (come il mio attuale player audio, Audacious) di cambiare il messaggio di stato di Pidgin.
Perchè tutto funzioni correttamente, è necessario che DBUS sia attivato e supportato dalla vostra copia di Pidgin. Ecco il sorgente dello script:
#!/bin/bash
APPNAME=$(basename $0)
PARAMETERS="$2 $3 $4 $5 $6 $7 $8 $9"
GREP=$(which grep)
AWK=$(which awk)
SED=$(which sed)
ECHO=$(which echo)
PURPLE_REMOTE=$(which purple-remote)
PURPLE_SEND=$(which purple-send)
PS=$(which ps)
CAT=$(which cat)
RM=$(which rm)
CURRENT_STATUS=$($PURPLE_REMOTE getstatus)
TEMPFILE_STATUS_MESSAGE=$HOME/$APPNAME.dbus-$($PS ax | $GREP -m1 "dbus-daemon" | $AWK '{ print $1 }').status-message
TEMPFILE_STATUS=$HOME/$APPNAME.dbus-$($PS ax | $GREP -m1 "dbus-daemon" | $AWK '{ print $1}').status
case "$1" in
"--backup-status" )
if [ -f $TEMPFILE_STATUS ]; then
$RM $TEMPFILE_STATUS
fi
$ECHO $CURRENT_STATUS >> $TEMPFILE_STATUS
;;
"--backup-status-message" )
if [ -f $TEMPFILE_STATUS_MESSAGE ]; then
$RM $TEMPFILE_STATUS_MESSAGE
fi
CURRENT_STATUS_ID=$($PURPLE_SEND PurpleSavedstatusGetCurrent | $GREP int32 | $AWK '{ print $2 }')
CURRENT_STATUS_MESSAGE=$($PURPLE_SEND PurpleSavedstatusGetMessage int32:$CURRENT_STATUS_ID | $GREP string | $SED -e "s/string//g" -e "s/\"//g" -e "s/ //g")
$ECHO $CURRENT_STATUS_MESSAGE >> $TEMPFILE_STATUS_MESSAGE
;;
"--set-status" )
$PURPLE_REMOTE setstatus?status="$2"
;;
"--set-status-message" )
$PURPLE_REMOTE setstatus?status=$CURRENT_STATUS\&message="$PARAMETERS"
;;
"--safe-set-status" )
if [ ! -f $TEMPFILE_STATUS ]; then
$0 --backup-status
fi
$0 --set-status $2
;;
"--safe-set-status-message" )
if [ ! -f $TEMPFILE_STATUS_MESSAGE ]; then
$0 --backup-status-message
fi
$0 --set-status-message $PARAMETERS
;;
"--clear-status" )
$0 --set-status ""
;;
"--clear-status-message" )
$0 --set-status-message ""
;;
"--restore-status" )
OLD_STATUS=$($CAT $TEMPFILE_STATUS)
$0 --set-status "$OLD_STATUS"
if [ -f $TEMPFILE_STATUS ]; then
$RM $TEMPFILE_STATUS
fi
;;
"--restore-status-message" )
OLD_STATUS_MESSAGE=$($CAT $TEMPFILE_STATUS_MESSAGE)
$0 --set-status-message "$OLD_STATUS_MESSAGE"
if [ -f $TEMPFILE_STATUS_MESSAGE ]; then
$RM $TEMPFILE_STATUS_MESSAGE
fi
;;
*)
$ECHO "$APPNAME: Wraps itself around the Pidgin command line utilities to (re)set, backup and restore"
$ECHO "the status message."
$ECHO ""
$ECHO "Hacked together by Emanuele Cipolla <bugs @emanuelecipolla.net>, 2008."
$ECHO "This script is released into the public domain."
$ECHO ""
$ECHO "WARNING: You _have to_ use a single option per run, no verification or simultaneous execution"
$ECHO "is made."
$ECHO ""
$ECHO "SYNOPSIS: $APPNAME [--backup-status]"
$ECHO "[--backup-status-message]"
$ECHO "[--set-status] [[status]]"
$ECHO "[--set-status-message] [[message]] [[...]]"
$ECHO "[--clear-status]"
$ECHO "[--clear-status-message]"
$ECHO "[--restore-status]"
$ECHO "[--restore-status-message]"
$ECHO ""
$ECHO "--backup-status Backups the current status to $TEMPFILE_STATUS."
$ECHO "--backup-status-message Backups the current status message to $TEMPFILE_STATUS_MESSAGE."
$ECHO "--set-status Sets the status."
$ECHO "--set-status-message Sets the status message."
$ECHO "--safe-set-status Sets the status after backing up the old one."
$ECHO "--safe-set-status-message Sets the status message after backing up the old one."
$ECHO "--clear-status Resets status to \"Online\"."
$ECHO "--clear-status-message Sets a blank status message."
$ECHO "--restore-status Restores back the status from $TEMPFILE_STATUS."
$ECHO "--restore-status-message Restores back the status message from $TEMPFILE_STATUS_MESSAGE."
;;
esac
Ecco, invece, come si presenta Audacious dopo essere stato configurato per l’utilizzo dello script, in seguito all’attivazione del plugin Song Change:

Lo screenshot è stato ritagliato
Enjoy.
Content for English-speaking readers in the works
I repeatedly noticed that a significant part of traffic coming to this website was from online translation services like Google Translate and Yahoo! Babel Fish. While the latter is completely automated, and no corrections - whether needed or not - can be submitted, I considered suggesting better translations to the service offered by Google, but I felt the whole thing was a bit awkward, so I started planning on publishing translations by my own.
They won’t be blind translations - I am going to revise the content, to avoid wasting time with information that might not be true any more or aren’t likely to be read. My statistics will be extremely helpful in figuring out what posts will get top priorities.
I think I’m not going to translate the whole site, either. While I’m mainly started looking at that because I haven’t “fresh” new content to publish in my mother language, my time and body energies are very limited, and so are likely to be in the very near future. There are no deadlines; this posts only states that some translations will be published sometime in the future.
I’d also like to ask fellow users to post relevant comments using the language my post was written in (English, Italian, maybe Klingon) to keep the communication flow intact and make me happy. My contact form is there for you to tell me (nearly) everything else.