Created
June 7, 2016 20:53
-
-
Save tlewiscpp/9dc8c7d0e74507ae82c8cc3778fd0257 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
declare -i SCREEN_WIDTH_POSITION=7 | |
declare -i SCREEN_HEIGHT_POSITION=9 | |
declare -i MINIMUM_SCREEN_WIDTH=1 | |
declare -i MAXIMUM_SCREEN_WIDTH=3840 | |
declare -i MINIMUM_SCREEN_HEIGHT=1 | |
declare -i MAXIMUM_SCREEN_HEIGHT=2160 | |
declare -i MOUSE_DELAY=100 | |
declare -i numberOfXArguments= | |
declare -i screenHeight= | |
declare -i screenWidth= | |
declare -i heightIndex= | |
declare -i widthIndex= | |
declare -i userReplied=0 | |
declare -i noWidth=0 | |
declare -i noHeight=0 | |
declare screenHeightRaw= | |
declare userEnteredWidth= | |
declare userEnteredHeight= | |
regEx='^[0-9]+$' | |
trap 'echo "Caught signal, exiting"; exit 0' 1 2 3 18 | |
trap 'echo "Thanks! See you later!";' EXIT | |
echo "Hello! Press CTRL+C at any point to quit" | |
returnString=$(xrandr | grep current) | |
read -r -a argumentArray <<< "$returnString" | |
declare -i numberOfXArguments=$((${#argumentArray[*]})) | |
if [[ $((numberOfXArguments)) -eq 0 ]]; then | |
echo "Something went wrong with xrandr, exiting." | |
exit 1 | |
fi | |
screenHeightRaw=${argumentArray[ $((SCREEN_HEIGHT_POSITION)) ]} | |
screenWidth=$(( ${argumentArray[ $((SCREEN_WIDTH_POSITION)) ]} )) | |
screenHeight=$(( ${screenHeightRaw:0:${#screenHeightRaw}-1} )) | |
echo "Your current resolution is $((screenWidth))x$((screenHeight))" | |
while [[ $userReplied -eq 0 ]]; do | |
read -p "Is this correct? [Y/n]" userReply | |
case $userReply in | |
y|Y) echo "Great. Here we go! (Press CTRL+C at any time to quit)"; userReplied=1 ;; | |
"") continue ;; | |
*) noWidth=1; noHeight=1; userReplied=1 ;; | |
esac | |
done | |
if [[ $((noWidth)) -eq 1 ]]; then | |
screenWidth=0 | |
while [[ $((screenWidth)) -eq 0 ]]; do | |
read -p "Enter your screen width in pixels: " userEnteredWidth | |
if ! [[ $userEnteredWidth =~ $regEx ]]; then | |
echo "Error: $userEnteredWidth is not a number" | |
elif [[ $((userEnteredWidth)) -lt $((MINIMUM_SCREEN_WIDTH)) ]]; then | |
echo "Error: $((userEnteredWidth)) is smaller than the minimum screen width of ($((MINIMUM_SCREEN_WIDTH))) pixels" | |
elif [[ $((userEnteredWidth)) -ge $((MAXIMUM_SCREEN_WIDTH)) ]]; then | |
echo "Error: $((userEnteredWidth)) is larger than the maximum screen width of ($((MAXIMUM_SCREEN_WIDTH))) pixels" | |
else | |
screenWidth=$((userEnteredWidth)) | |
fi | |
done | |
fi | |
if [[ $((noHeight)) -eq 1 ]]; then | |
screenHeight=0 | |
while [[ $((screenHeight)) -eq 0 ]]; do | |
read -p "Enter your screen height in pixels: " userEnteredHeight | |
if ! [[ $userEnteredHeight =~ $regEx ]]; then | |
echo "Error: $userEnteredHeight is not a number" | |
elif [[ $((userEnteredHeight)) -lt $((MINIMUM_SCREEN_HEIGHT)) ]]; then | |
echo "Error: $((userEnteredHeight)) is smaller than the minimum screen height of ($((MINIMUM_SCREEN_HEIGHT))) pixels" | |
elif [[ $((userEnteredHeight)) -ge $((MAXIMUM_SCREEN_HEIGHT)) ]]; then | |
echo "Error: $((userEnteredHeight)) is larger than the maximum screen height ($((MAXIMUM_SCREEN_HEIGHT))) pixels" | |
else | |
screenHeight=$((userEnteredHeight)) | |
fi | |
done | |
fi | |
while(true); do | |
for ((heightIndex = 0; heightIndex < screenHeight; heightIndex++)); do | |
for ((widthIndex = 0; widthIndex < screenWidth; widthIndex++)); do | |
xdotool mousemove $((widthIndex)) $((heightIndex)) | |
echo -ne "currentPixel: ($((widthIndex)),$((heightIndex)))\r" | |
done | |
echo -ne "\r\033[K\r" | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment