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

24 lines
657 B
Bash
Executable file

#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
. /etc/profile
BRIGHTNESS_DEV="$(ls /sys/class/backlight | head -n 1)"
### 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" $(echo "${BRIGHTNESS}"))
echo ${BRIGHTNESS} > /sys/class/backlight/${BRIGHTNESS_DEV}/brightness
set_setting system.brightness ${BRIGHTNESS}