bash script to keep mouse activity
Task: Write bash script to keep mouse activity
Solution:
Use next script body commands:
#!/bin/bash
#
# Emulating movement of mouse (randomly move up or
# down or left or right to 1 pixel every 10 seconds).
#
_dev=$(ls -1 /dev/input/by-id/*event-mouse | tail -1)
[ -z "${_dev}" ] && echo "Cannot find mouse event device" && exit 1
echo "Using ${_dev}"
while [ true ]
do
sleep 10
case $(($RANDOM%4)) in
0)
echo "Up"
/usr/bin/evemu-event ${_dev} --type EV_REL --code REL_Y --value -1 --sync
;;
1)
echo "Down"
/usr/bin/evemu-event ${_dev} --type EV_REL --code REL_Y --value 1 --sync
;;
2)
echo "Left"
/usr/bin/evemu-event ${_dev} --type EV_REL --code REL_X --value -1 --sync
;;
3)
echo "Right"
/usr/bin/evemu-event ${_dev} --type EV_REL --code REL_X --value 1 --sync
;;
esac
done
Put code above into some keep-mouse-activity.sh file;
Set executable attributes and run it;
Done.