If you already are a CIM user, you should know CIM support Auto away after some idling time. The setting looks like:

 Auto Presence
    Automatically set Away period (min) : 0
    Automatically set N/A period (min) : 0
    Automatically set N/A when screen is detached : no

However, you should also know it only detects the activity within that terminal window/virtual consoles, your activity in X would not be detected.

My first thought is to use xautolock, but it only lets you run a program when idling time reaches a threshold. If you move your mouse or type something, there is no way that xautolock runs another program after resuming activity. You have to manually set the status back to online or something else in CIM.

1   XSS binding

You need PyXSS or pxss.py.

1.1   PyXSS

So, I thought I should tear the code and make it to do what I want. Thank God! I didnt have to! Because I found a Python library, PyXSS. Its quite old, but still operable. It relies on the XScreenSaver extension, you need it with your X Server. The version I use is 2.1, there is problem with it. Its setup.py didnt work at some point.

Find this line:

setup(name='PyXSS', version=2.1,

And change to (make the version number to be string type)

setup(name='PyXSS', version='2.1',

python setup.py install should now install PyXSS normally.

1.2   pxss.py

It has similar functionality to PyXSS but you dont need to install it, just put it with CIM_status_setter.py. It accomplishes same tasks using ctypes.

2   CIM_status_setter.py

So, I used PyXSS or pxss.py to write a Python script, CIM_status_setter.py. I have to say this not the best way, because if you write in C, it will use less memory.

I am not going to explain the Python code. I just tell you how to use it. Once you run it, it shows you:

Keys
 h - Show help
 * - Detect idling
 o, _, a, d, n, c, f, i - Change status
[*][o] Online   Welcome back!

2.1   Detect mode

If you press *, then it will be activated the detect mode, which is the whole point. Its turned on by default and the idling time is 300 seconds. Five minutes without activities, it will ask CIM to change the status to Away for MSN and Jabber protocols. You can see the protocols or idling you need in that script, no command-line options or configuration file, sorry!

If you move mouse or type something, it should be asking CIM to change to Online in a few seconds.

Note

The status only goes back and forth between Online and Away in Detect mode.

2.2   Fixed status mode

If you press o (Online), d (Do not disturb), etc., it sets status to what you want. The keys are the same you see in CIMs status menu.

Note that entering Fixed status mode disables Detect mode. You have to press * to go back to Detect mode.

3   GNU/Screen

I believe many of CIM users, run CIM within Screen to prevent accidentally terminal window closing. You can create a new configuration file for CIM and this Python script.

For example, a configuration file called ~/.screen_centerimrc:

source $HOME/.screenrc
screen centerim
screen CIM_status_setter.py
select 0

Make sure the script is in your PATH or use full path, it also sources your original Screen configuration.

I use FluxBox, so I have this command in my menu:

urxvtc -title centerim -e screen -c ~/.screen_centerimrc

urxvtc is a client program for URxvt daemon. You can use urxvt or the terminal emulator you use but you have to check man page for a equivalent -e option.

4   Final Notes

This script was written in rush. It is not perfect, feel free to tweak it. One more thing, CIM doesnt update its screen if you just send a status change to it. You need to resize the window to force redraw screen (Ctrl+L doesnt work) to make sure you read correct statuses on top-right corner.

After I finished, I realized there is no need to use thread. But you know, I am lazy!

The new version does not use thread anymore and it updates your terminals or screens window title.


Updated on 2009-10-27: Added pxss.py information and the updates of script.