-
-
Save benjamin051000/6e763a562afbf0d6a499d1aee8ced62e to your computer and use it in GitHub Desktop.
spin your monitor around, slowly but surely
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 | |
# make sure we're not on Wayland, because xrandr doesn't work on Wayland | |
if [ "$(loginctl show-session $(loginctl user-status $USER | grep -E -m 1 'session-[0-9]+\.scope' | sed -E 's/^.*?session-([0-9]+)\.scope.*$/\1/') -p Type | grep -ic "wayland")" -ge 1 ]; then # stolen from stackoverflow | |
echo "You aren't using X!" | |
exit | |
fi | |
# no more annoying cursor | |
tput civis | |
# return back to normal when killed because you got bored | |
trap cleanup 1 2 3 6 | |
cleanup() { | |
printf '\n%s\n' 'Putting display back to normal...' | |
sleep 1 # allow you to read the text it prints | |
xrandr --output "$o" --transform none # un-magic | |
tput cnorm # give cursor back | |
exit | |
} | |
# get primary display output name | |
o=$(xrandr | awk '/ primary / {print $1}') | |
# convert degrees to radians | |
dr () { | |
echo "$1 * 0.01745329" | bc -l | |
} | |
# do the funny | |
i=1 | |
j=0 | |
while true; do | |
xrandr --output "$o" --transform $(echo "c($(dr $i))" | bc -l),$(echo "-s($(dr $i))" | bc -l),0,$(echo "s($(dr $i))" | bc -l),$(echo "c($(dr $i))" | bc -l),0,0,0,1 # magic | |
printf '\033[2K%s\033[1m%s\033[m\n' "CURRENT ANGLE: " "$i°" | |
printf '\033[2K%s\033[1m%s\033[m\r\033[1A' "ROTATIONS SUFFERED: " "$j" | |
i=$((i+1)) | |
if [ $i == 360 ]; then | |
j=$((j+1)) | |
fi | |
i=$((i%360)) # don't fuck off to infinity | |
sleep 5 # give your screen some time to rest | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment