31 lines
473 B
Bash
Executable File
31 lines
473 B
Bash
Executable File
#!/bin/sh
|
|
|
|
# Set brightness for laptops backlight
|
|
|
|
PATH="$HOME/.local/bin:$PATH"
|
|
|
|
# brightness values
|
|
night=1000
|
|
transition=1500
|
|
daytime=2000
|
|
|
|
deref() {
|
|
eval "echo \$$1"
|
|
}
|
|
|
|
fade_to() {
|
|
current=$(brightness)
|
|
echo "$current $1"
|
|
step=10
|
|
[ "$current" -gt "$1" ] && sign=- || sign=+
|
|
for i in $(seq "$current" "${sign}$step" "$1"); do
|
|
brightness "$sign" "$step" > /dev/null
|
|
sleep 1
|
|
done
|
|
}
|
|
|
|
|
|
if [ "$1" = "period-changed" ]; then
|
|
fade_to "$(deref "$3")"
|
|
fi
|