Created
June 24, 2019 15:13
-
-
Save CptSpaceToaster/e74705821f538877c2b67daeda5492f6 to your computer and use it in GitHub Desktop.
This file contains 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
PERIOD=300 | |
AMPLITUDE=6000 | |
O1=$((PERIOD/3)) | |
O2=$((O1*2)) | |
UUID=$(osascript -e "tell application \"iTerm2\" | |
get current session of current window | |
end tell" | cut -d' ' -f3 -f6 -f10) | |
set-background() { | |
osascript -e "tell application \"iTerm2\" | |
tell window id $3 | |
tell tab $2 | |
tell session id \"$1\" | |
set background color to $4 | |
end tell | |
end tell | |
end tell | |
end tell" 2>/dev/null || exit | |
} | |
if [ -z ${1+x} ]; then | |
LOOP=false | |
else | |
LOOP=true | |
fi | |
c() { | |
bc -l <<< "scale=0;m=$1%$PERIOD;scale=20;if(m>$O2){0}else{n=(c(12*a(1)*m/$PERIOD+4*a(1))+1)*$AMPLITUDE;scale=0;n/1}" | |
} | |
while true; do | |
for ((i=1;i<=PERIOD;i++)); do | |
set-background $UUID "{$(c $i), $(c $((i+O1))), $(c $((i+O2))), 0}" | |
done | |
$LOOP || break | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This uses an unfortunately large amount of CPU right now...