distribution/packages/jelos/sources/autostart/common/006-brightness

29 lines
805 B
Text
Raw Normal View History

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
2022-09-29 20:44:45 +00:00
BRIGHTNESS_DEV="$(ls /sys/class/backlight)"
2022-08-31 11:00:57 +00:00
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
BRIGHTNESS=${DEVICE_BRIGHTNESS}
fi
# Ensure user doesn't get "locked out" with super low brightness
if [[ "${BRIGHTNESS}" -lt "3" ]]
then
BRIGHTNESS=3
fi
2022-09-29 20:44:45 +00:00
BRIGHTNESS=$(printf "%.0f" ${BRIGHTNESS})
if [ "$(cat /sys/class/backlight/${BRIGHTNESS_DEV}/max_brightness)" = 255 ]
then
printf "%.0f" $(echo "${BRIGHTNESS} * 2.56" | bc) > /sys/class/backlight/${BRIGHTNESS_DEV}/brightness
else
printf "%.0f" $(echo "${BRIGHTNESS}") > /sys/class/backlight/${BRIGHTNESS_DEV}/brightness
fi