#!/bin/bash # SPDX-License-Identifier: Apache-2.0 # Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius) . /etc/profile tocon "Configuring backlight..." ### Variables may need to be device specific here. BRIGHTNESS=$(get_setting system.brightness) if [[ ! "${BRIGHTNESS}" =~ [0-9] ]] then if [ "${DEVICE_BRIGHTNESS}" = "hardware" ] then BRIGHTNESS=$(cat /sys/class/backlight/$(brightness device)/brightness 2>/dev/null) else BRIGHTNESS=${DEVICE_BRIGHTNESS} fi fi # Ensure user doesn't get "locked out" with super low brightness if [[ "${BRIGHTNESS}" -lt "3" ]] then BRIGHTNESS=3 fi BRIGHTNESS_DEVICE="$(brightness device)" if [ -e "/sys/class/backlight/${BRIGHTNESS_DEVICE}/brightness" ] then printf "%.0f" $(echo "${BRIGHTNESS}") > /sys/class/backlight/${BRIGHTNESS_DEVICE}/brightness fi