Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@CptSpaceToaster

This comment has been minimized.

Copy link
Owner Author

@CptSpaceToaster CptSpaceToaster commented Jun 24, 2019

This uses an unfortunately large amount of CPU right now...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment