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
|
|
|
|
|
2023-04-22 20:01:07 +00:00
|
|
|
tocon "Configuring backlight..."
|
|
|
|
|
2022-02-05 14:23:32 +00:00
|
|
|
### Variables may need to be device specific here.
|
|
|
|
BRIGHTNESS=$(get_setting system.brightness)
|
|
|
|
if [[ ! "${BRIGHTNESS}" =~ [0-9] ]]
|
|
|
|
then
|
2023-04-22 20:01:07 +00:00
|
|
|
if [ "${DEVICE_BRIGHTNESS}" = "hardware" ]
|
|
|
|
then
|
|
|
|
BRIGHTNESS=$(cat /sys/class/backlight/$(brightness device)/brightness 2>/dev/null)
|
|
|
|
else
|
|
|
|
BRIGHTNESS=${DEVICE_BRIGHTNESS}
|
|
|
|
fi
|
2022-02-05 14:23:32 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Ensure user doesn't get "locked out" with super low brightness
|
|
|
|
if [[ "${BRIGHTNESS}" -lt "3" ]]
|
|
|
|
then
|
|
|
|
BRIGHTNESS=3
|
|
|
|
fi
|
2022-09-05 10:58:27 +00:00
|
|
|
|
2023-02-08 17:26:54 +00:00
|
|
|
BRIGHTNESS_DEVICE="$(brightness device)"
|
|
|
|
if [ -e "/sys/class/backlight/${BRIGHTNESS_DEVICE}/brightness" ]
|
|
|
|
then
|
|
|
|
printf "%.0f" $(echo "${BRIGHTNESS}") > /sys/class/backlight/${BRIGHTNESS_DEVICE}/brightness
|
|
|
|
fi
|
2023-04-01 00:20:39 +00:00
|
|
|
|