Comment 4 for bug 268780

Revision history for this message
Zakhar (alainb06) wrote :

I do agree with your answer, it's what I suggest as possible anwser n°1.
Basically, if the answer is so, what I say is there is still a bug... in the documentation. Because who is a 30 years old *ix legacy, at this time a mouse was not a frequent input device, hence the documentation does not mention it. Nowadays, when someone reads on a documentation: "user is idle", he is bound to think: no mouse input.
So I'm fine with the answer, but "man-people" (or is it core-utils people ?) should modify the man pages about who so that it is clear to everyone reading that idle means only "no keystrokes" were made, and that mouse or other input devices are not taken into account.

Let's go back to my scenario.
I have a PC (with Hardy) that is used either
- as a regular PC: someone is in front of the PC doing some stuff!
or
- as an unattended streaming server, to stream movies (uses VLC with local ISP as source).
When PC is used as an unattended server, it is powered on from a distant location using Wake On Wan.
From this distant location we can then look video streams (French TV), and of course, the remote interface has a button to stop the server. But sometimes, we just exit the remote interface and forget to hit the shutdown-the-server button.
In that case, I don't want the remote server to remain powered on for hours or even days! Of course, it is why Wake On Wan is used also, because remote server is powered down by default when not in use.

So, I saw a small cron'ed-script someone made public on the Ubuntu forum, to auto-power-down a PC on "inactivity".
I adapted the script a little bit, because when someone is watching TV from the remote location it has to be detected as "activity". That is done with the remote-player (I adapted VLC HTTP interface remote HTML pages that are quite buggy by the way!), it sends an Ajax (XHR) request to the server every minute to mark its remote activity.

So the script has this logic:
- if it ever sees "local activity", it will never power down the PC (means someone is here, we do not want to shutdown PC then)
- if it sees "remote" activity : do not stop the PC
- if after 10 minutes, there is no "remote" activity, and never seen any "local activity" => shutdown.

As the example on the forum used who, I did the same.

I ran in this "who issue", when one day my father used the PC locally to watch a movie. As he did that without ever touching the keyboard, only mouse moves & clicks, who detected no local activity and PC was shutdown after 10 minutes!

So who was a "solution" (not a good one obviously).
The "need" is to detect properly user activity (including mouse, touchpad, joystick, tablet....)

I would be very glad if there were some way to do that, such as look into some /proc/idle (which does not exist, I'm making that up!)

Writing this cron'ed script, I was mislead by the documentation saying who reports "idle user".

So to sumarize:
- who does not report mouse activity.
- it's OK as who is very old stuff, and relies on "bad" architecture, we do not want to change it.
- anyway, as mouse is so obvious nowadays, I strongly suggest documentation (man pages) is changed to mark who limitation to keyboard only.
- therefore we are loosing a feature which is "real" idle user time (including mouse).
- this feature might exist somewhere else (if you know where, I'll be very glad to learn!). If so, while changing the man pages for who, it could also be added a note to where to look for "real" idle user time (mouse included).
- if the feature does not exist, if should be developped ;-)

I don't know if this feature is relevant to "coreutils" or to "graphical interface". Obviously for example I can't think of a scenario you will need this feature on a "server-version" of *ix, because a "server-version" won't even have a graphical interface. So on a server version, the 30 years old who is perfect!

Now I'll wait a while, if someone could point me to an existing way to know the real idle user time including mouse moves and clicks.

If no one knows of such a feature, I'll try to set up a C environment and make a small program for that, and submit it... if I succeed doing something that works!

After that, I don't know how things are decided (is there a W3C equivalent that normalizes linux) but 2 things are possible:
- keep the "idle reporter" a separate utility program
- bind it to who with an option (is there someone normalising options in linux commands?). It would just need adding a test to who: if option is present (-X for instance), and who can detect an X server, then call the "utiliy" to report accurate idle time instead of reading it from /var/utmp