aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2018-08-22 04:48:45 -0400
committerB. Watson <yalhcru@gmail.com>2018-08-22 04:48:45 -0400
commitd53b768678f8d3e9d7fb17d6b6ad3fa562c98911 (patch)
tree0a0254e93a66fa7b874c666ab487f846235f6bb9
parenta8848d466f5aead07cb8d848e228f00b26697ef0 (diff)
downloadmisc-scripts-d53b768678f8d3e9d7fb17d6b6ad3fa562c98911.tar.gz
Add silly gammatrip script (it's all dive's fault!)
-rwxr-xr-xgammatrip.sh62
1 files changed, 62 insertions, 0 deletions
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