#!/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