Mousemover to prevent idle?

Is there any working utility that can simulate mouse movements on a ubuntu?

Important: I only want that utility to control the mouse if the machine is idle for X minutes.

Of course I could use xdotool to simulate some movement, but how would I detect if the pc is idle for x minutes? I could not find any working tool for linux...


Solution 1:

There's a program that moves the mouse when it detects you are away, or idle.

https://github.com/carrot69/keep-presence/

You can install it from snap:

sudo snap install keep-presence

Then run it:

keep-presence --seconds 30

It will move the mouse after 30 seconds if it detects that you are idle.

Solution 2:

Meanwhile I created my own script:

#requires:
# 'xprintidle' for inactivity check (in ms)
# 'rand' for generating random number (screen resolution)
# 'xdotool' to move the mouse pointer

#parameters:
# 100000 idle time in ms before executing the mousemove
# 800 / 600: your screen resolution, at at least the moving range for the mouse pointer

while :; do
    if  [ $(xprintidle) -gt 100000 ]
    then
        xdotool mousemove `rand -M 800` `rand -M 600`;
    fi

    sleep 30
done