2022-03-28 23:53:26 +00:00
|
|
|
#!/bin/bash
|
2022-02-05 14:23:32 +00:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
|
|
|
|
|
|
|
|
. /etc/profile
|
|
|
|
|
|
|
|
### Variables may need to be device specific here.
|
|
|
|
BRIGHTNESS=$(get_setting system.brightness)
|
|
|
|
if [[ ! "${BRIGHTNESS}" =~ [0-9] ]]
|
|
|
|
then
|
|
|
|
BRIGHTNESS=${DEVICE_BRIGHTNESS}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Ensure user doesn't get "locked out" with super low brightness
|
|
|
|
if [[ "${BRIGHTNESS}" -lt "3" ]]
|
|
|
|
then
|
|
|
|
BRIGHTNESS=3
|
|
|
|
fi
|
|
|
|
BRIGHTNESS=$(printf "%.0f" ${BRIGHTNESS})
|
2022-04-07 21:30:40 +00:00
|
|
|
if [ "$(cat /sys/class/backlight/backlight/max_brightness)" = 255 ]
|
|
|
|
then
|
2022-04-08 01:29:27 +00:00
|
|
|
printf "%.0f" $(echo "${BRIGHTNESS} * 2.56" | bc) > /sys/class/backlight/backlight/brightness
|
|
|
|
else
|
|
|
|
printf "%.0f" $(echo "${BRIGHTNESS}") > /sys/class/backlight/backlight/brightness
|
2022-04-07 21:30:40 +00:00
|
|
|
fi
|
2022-02-05 14:23:32 +00:00
|
|
|
set_setting system.brightness ${BRIGHTNESS}
|