blob: 2b81a09e55fadfe1c015f2599c1b21e584a9974e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
|