From d53b768678f8d3e9d7fb17d6b6ad3fa562c98911 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 22 Aug 2018 04:48:45 -0400 Subject: Add silly gammatrip script (it's all dive's fault!) --- gammatrip.sh | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 gammatrip.sh diff --git a/gammatrip.sh b/gammatrip.sh new file mode 100755 index 0000000..2b81a09 --- /dev/null +++ b/gammatrip.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# gammatrip.sh by B. Watson, licensed under the WTFPL. +# Randomly change gamma in X, crude simulation of an acid trip. +# It's also similar to the Atari 400/800/XL/XE "Atrract Mode" + +#### user-tweakable knobs: + +# seconds to sleep between gamma changes +DELAY=${DELAY:-3} + +# max gamma for each individual color. lower number here means darker +# colors on average. Units are 1/100ths of xrandr's --gamma floats, +# MAX=100 means 1.0. Maximum value for MAX is 999. +MAX=${MAX:-100} + +# minimum gamma for each color. don't set higher than MAX! +# same units as MAX. +MIN=${MIN:-30} + +#### end of user-tweakable knobs. + +init() { + trap cleanup SIGINT SIGABRT SIGHUP SIGTERM + OUTPUT="${OUTPUT:-$( xrandr | grep ' connected' | cut -d' ' -f1 )}" + echo "Using output '$OUTPUT'" +} + +cleanup() { + echo "Restoring default gamma" + xrandr --output "$OUTPUT" --gamma "1.0:1.0:1.0" + exit 0 +} + +getrand() { + range=$(( MAX - MIN )) + echo $(( ( RANDOM % range ) + MIN )) +} + +cycle() { + r=0; g=0; b=0 + r="$( getrand )" + g="$( getrand )" + b="$( getrand )" + cmd="xrandr --output $OUTPUT --gamma " + for i in $r $g $b; do + cmd="$cmd$( printf "%03d" $i | sed 's,^.,&.,' ):" + done + + # remove trailing colon. actually, xrandr doesn't care about it, + # but someday it might. + cmd="$( echo $cmd | sed 's,:$,,' )" + + echo $cmd + $cmd +} + +init +while true; do + cycle + sleep "$DELAY" +done -- cgit v1.2.3