SunRay hot desking and Gaim away
On Friday James had an interesting idea about setting the away status of Gaim, the default GNOME (and therefore Java Desktop System (JDS)) IM client, based on insert/remove actions of the SunBadge many Sun employees use to access their remote X sessions.
SunRay software and hardware is pretty great stuff and works on the concept of tying a token card (SunBadge) to an X session. The first time you use the card you log in on a thin client with a standard username/password to create a persistent session on a central server, which is then associated with the token card. On removal of the card the thin client becomes free for anybody else to use while the session remains active on the central server. Next time you need your desktop back, you simply insert the token card in a free client and pick up where you left off. In more advanced setups the software can be configured to allow “hot desking” between networks or regions (i.e. connecting to a session running in England from a thin client in Japan (Sun call this “regional hot desking”)).
After a little thought it became clear that all of the elements existed to implement an auto-away as described earlier. Gaim can be extended by writing plug-ins that have access to a powerful API and SunRay sessions can be “extended” using utaction to execute code on session connection and disconnection.
Perl plugin support was broken in my Gaim build and I was uanble to get the GaimAccountSetStatus Gaim D-Bus call to work properly so I turned to #gaim on Freenode and was directed towards gaim-remote.pl, which had helpfully been excluded from my Gaim installation. Using one simple command I can change the state of all Gaim accounts, in this example to the Away state with a helpful message:
gaim-remote.py setstatus?status=away&message="I am not currently connected to a SunRay"
Tying this command into utaction is very straightforward:
utaction -c 'gaim-remote.py setstatus?status=available' -d 'gaim-remote.py setstatus?status=away\&message="I am not currently connected to a SunRay"' -t 30 &
Here it’s easy to see that -c is the command to run on connection, -d the command on disconnection and -t is used to specify a timeout after (dis)connection before the command is executed. I added 30s here because it is common for us to let another user very quickly use our SunRay client, during which time we are not really “away”.
I see no reason why this won’t work as-is, but without having had chance to test it, I can’t say for sure. What does annoy me a little is that the SunRay server software provides no clean way of allowing a user to specify a connect/disconnect script that persists between sessions (i.e. if the central server is restarted or I manually log out for any reason). It’s not a massive problem, but adding the utaction command to GNOME’s Startup Programs is not the end of the world.
Tags: UNIX