forked from DougieLawson/backlight_dimmer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-timeout.sh
executable file
·31 lines (29 loc) · 1.12 KB
/
run-timeout.sh
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
#!/usr/bin/env bash
# Run program to turn off RPi backlight after a period of time,
# turn on when the touchscreen is touched.
# Best to run this script from /etc/rc.local to start at boot.
timeout_period=30 # seconds
# Find the device the touchscreen uses. This can change depending on
# other input devices (keyboard, mouse) are connected at boot time.
for line in $(lsinput); do
if [[ $line == *"/dev/input"* ]]; then
word=$(echo $line | tr "/" "\n")
for dev in $word; do
if [[ $dev == "event"* ]]; then
break
fi
done
fi
if [[ $line == *"FT5406"* ]] ; then
break
fi
done
# Use nice as it sucks up CPU.
# Timeout is in /usr/local/bin so as not to conflict with /bin/timeout
# /usr/local/bin/timeout <timeout> <input_device>
#nice -n 19 /usr/local/bin/timeout $timeout_period $dev &
echo "$timeout_period"
echo "$dev"
echo "Start backlight dimmer"
sudo bash -c "echo 255 > /sys/class/backlight/10-0045/brightness"
nice -n 19 /usr/local/bin/timeout $timeout_period $dev &