mouseMover.bash

Little fun script to keep your mouse pointer changing position, keeping your screen alive and stopping the screensaver from kicking in 🙂

Here is the code:

#!/usr/bin/env bash

# Check if xte is installed
if ! command -v xte &> /dev/null
then
    echo "COMMAND \"xte\" could not be found"
    exit
fi


# Get width of the screen
Xaxis=$(xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f1)

# Get Hght of the screen
Yaxis=$(xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f2)

while true; 
do 
	# generate random number based on Xaxis & Yaxis
	Xmove=$((1 + $RANDOM % $Xaxis))
	Ymove=$((1 + $RANDOM % $Yaxis))
	
	# xte move the mouse based on the new random number generated
	xte "mousemove `echo $Xmove` `echo $Ymove`"; 
	
	# print out new position on the screen
	echo $Xmove x $Ymove;
	
	# sleep for 10 seconds.
	sleep 10; 
done

Enjoy it!