An elderly relative uses a Ubuntu 18.04 + LXDE desktop, mostly just for internet browsing and to play a few word games. They rarely shut the PC down...last time I checked, it had been turned on for over 15 days.
I administer the system remotely over ssh.
For the occasional time that I need to reboot the system, I'd like some means to determine if my relative is actively using it so that I don't disrupt them. I've done it in the middle of the night sometimes, but they sleep poorly and sometimes get up and play their games then.
Calling them on the phone works, but there are several time zones between us, and sometimes it wakes them up.
If they are playing a game, I can see that in top
, but I can't find a way to tell if they are actively using the browser.
Some kind of mouse and/or keyboard activity indicator would be awesome, but I wish to stay away from any kind of keylogger type software. I suspect such a "mouse/keyboard activity detected" thing exists - to put the system to sleep / activate the screensaver** and wake it up if for nothing else - but I can't find it.
** I don't think they actually use a screensaver, that was just an example. I think the power manager just blanks the screen.
Is there a "time since last keyboard/mouse interaction from user" tracked somewhere?
Any solutions need to be do-able over ssh.
There exists an utility to print the idle time of the X screen:
It prints the time since last keyboard or mouse input in milliseconds.
Another option would be to pop up a question box:
Then if you get no answer within a few minutes, just ctrl-c it out and proceed to reboot.
If the monitor is configured to save energy, you may check it:
Look at last line:
Well... this is only an idea, but if you login via ssh to the same user that your relative is using, set the
DISPLAY
environment variable to:1
and runxinput test n
wheren
is the number corresponding to the mouse (you can obtain that number withxinput --list
, in my case it's 9), then that command will print a line of text (in form likemotion a[0]=338 a[1]=889
) whenever the mouse is moved. So you can pipe the output from that command to some script that will record time when it last got any input, thus you will know when the mouse has been last moved (of course this has to run constantly in the background to record actual time of last mouse movement).I think the only way you're going to know for absolutely sure is to "spy" on their screen.
Install x11vnc on their computer with
sudo apt-get install x11vnc net-tools
(Optional) Create a shell script on their computer to automate the process of starting the server, so you don't have to remember the syntax every time. Note that the
-auth
parameter may need to be changed; I only have Fedora to test with right now, and Ubuntu might save the auth file in a different location.Install your favorite VNC viewer application on your computer.
Set up SSH port tunneling for port 5900 on your computer. Assuming you're using OpenSSH, put the following in your
.ssh/config
file:When you want to actually look at their screen:
SSH into their computer as normal.
Run the shell script (or type out that big
sudo x11vnc
line).*Start your VNC viewer application, and direct it to connect to
localhost
.Voila, you should be able to see their screen.
*Note: You're going to get several warnings that the VNC server isn't protected by a password. This isn't a security risk, since the VNC server port can only be accessed locally, meaning that any attacker would have to already be logged in. If you're really concerned, though, use
x11vnc -storepasswd
to create a password file, then add-rfbauth /home/user/.vnc/passwd
to thex11vnc
command line.