uidle - output idle time for specified user
$ uidle --help
Finds the session with the smallest idle time corresponding to the specified user and by default outputs the number of seconds idle.
uidle primarily relies on being able to extra idle time from the atime
of the tty referred to in the ut_line
field of the utmp
struct for active login sessions.
Some distros such as Fedora 16 seem to set a ut_line
field value for the Xorg display which relates to one of the Linux virtual consoles:
$ who
adam tty1 2010-01-20 11:03 (:0)
However, distros such as openSUSE 12.2 instead write :0
to the ut_line
field:
$ who
adam :0 Oct 9 09:05 (console)
On older Fedora, the atime
of /dev/tty1 would also be updated even by a mere press of a Shift key on the :0 display (although not by a mouse pointer movement). This provided a helpful way of detecting keyboard activity on the X console.
Unfortunately, on Fedora 16 and openSUSE 12.2, it seems that X keyboard activity no longer updates the atime
of any /dev/tty[0-9] device. This leaves two avenues for obtaining accurate idle time:
from idle times for individual ptys
This first can only work if urxvt/xterm etc. are setuid or setgid, so they can update utmp. By default, openSUSE does not ship them in this way, so you need to make them so, e.g.
chgrp utmp `which urxvt` chmod g+s `which urxvt`
x11idle
Alternatively, or in addition, ensure x11idle.c from org-mode's contrib/scripts/ directory is compiled and installed on the
$PATH
, and then runuidle
with the-x
option. This uses the Xss1 library to give very accurate idle time; however, it counts mouse pointer movement as activity, which with a twitchy mouse could accidentally cause a machine shutdown in the middle of the night ifroutine
is running.
Returns success (zero) if an idle time was found, or failure (1) otherwise.
Adam Spiers <[email protected]>