Switch brightness and volume to use increments of 10.
This commit is contained in:
parent
dc524f2a4d
commit
c04fa39059
6 changed files with 63 additions and 69 deletions
|
@ -8,27 +8,18 @@ tocon "Configuring display..."
|
|||
|
||||
### Variables may need to be device specific here.
|
||||
BRIGHTNESS=$(get_setting system.brightness)
|
||||
if [[ ! "${BRIGHTNESS}" =~ [0-9] ]]
|
||||
if [[ -z ${BRIGHTNESS} ]]
|
||||
then
|
||||
if [ "${DEVICE_BRIGHTNESS}" = "hardware" ]
|
||||
then
|
||||
BRIGHTNESS=$(cat /sys/class/backlight/$(brightness device)/brightness 2>/dev/null)
|
||||
else
|
||||
BRIGHTNESS=${DEVICE_BRIGHTNESS}
|
||||
fi
|
||||
BRIGHTNESS="6"
|
||||
fi
|
||||
|
||||
# Ensure user doesn't get "locked out" with super low brightness
|
||||
if [[ "${BRIGHTNESS}" -lt "3" ]]
|
||||
if [[ "${BRIGHTNESS}" = "0" ]]
|
||||
then
|
||||
BRIGHTNESS=3
|
||||
BRIGHTNESS=1
|
||||
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
|
||||
brightness set ${BRIGHTNESS}
|
||||
|
||||
### Set the aspect ratio in ES.
|
||||
ASPECT=$(get_aspect_ratio)
|
||||
|
|
|
@ -38,7 +38,7 @@ cps3.integerscale=0
|
|||
daphne.integerscale=0
|
||||
daphne.ratio=4/3
|
||||
desktop.enabled=0
|
||||
display.brightness=50
|
||||
display.brightness=5
|
||||
display.contrast=50
|
||||
display.hue=50
|
||||
display.saturation=50
|
||||
|
|
|
@ -2,20 +2,13 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Copyright (C) 2020-present Fewtarius
|
||||
|
||||
BRIGHTNESS_DEV="$(ls /sys/class/backlight | head -n 1)"
|
||||
|
||||
MIN=1
|
||||
MAX=$(cat /sys/class/backlight/${BRIGHTNESS_DEV}/max_brightness)
|
||||
if [ "${MAX}" = 255 ]
|
||||
then
|
||||
STEP=17
|
||||
else
|
||||
STEP=6
|
||||
fi
|
||||
BRIGHTNESS_DEV="$(find /sys/class/backlight/*/ -name brightness -print -quit)"
|
||||
BRIGHTNESS_PATH="${BRIGHTNESS_DEV%/brightness}"
|
||||
|
||||
if [[ -n "$2" ]]; then
|
||||
STEP=$2
|
||||
fi
|
||||
MIN=0
|
||||
MAX=$(<$(find /sys/class/backlight/*/ -name max_brightness -print -quit))
|
||||
STEP=$(( ${MAX} / 10 ))
|
||||
|
||||
# Ensure set_setting exists in all contexts
|
||||
if ! type set_setting &>/dev/null
|
||||
|
@ -23,53 +16,58 @@ then
|
|||
source /etc/profile
|
||||
fi
|
||||
|
||||
if [ ! -f /sys/class/backlight/${BRIGHTNESS_DEV}/brightness ]
|
||||
if [ ! -f "${BRIGHTNESS_DEV}" ]
|
||||
then
|
||||
echo "ERROR: There is no BRIGHTNESS object to manage."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
getBrightness() {
|
||||
echo $(<${BRIGHTNESS_DEV})
|
||||
}
|
||||
|
||||
setBrightness() {
|
||||
echo "${1}" > ${BRIGHTNESS_DEV}
|
||||
set_setting system.brightness "$(( ${1} / ${STEP} ))"
|
||||
}
|
||||
|
||||
stepUp() {
|
||||
getBrightness
|
||||
MYBRIGHTNESS=$?
|
||||
MYBRIGHTNESS=$(getBrightness)
|
||||
NEWBRIGHTNESS=$((${MYBRIGHTNESS}+${STEP}))
|
||||
if (( ${NEWBRIGHTNESS} > ${MAX} ))
|
||||
then
|
||||
NEWBRIGHTNESS=${MAX}
|
||||
fi
|
||||
echo "${NEWBRIGHTNESS}" > /sys/class/backlight/${BRIGHTNESS_DEV}/brightness
|
||||
set_setting system.brightness ${NEWBRIGHTNESS}
|
||||
setBrightness ${NEWBRIGHTNESS}
|
||||
}
|
||||
|
||||
stepDown() {
|
||||
getBrightness
|
||||
MYBRIGHTNESS=$?
|
||||
MYBRIGHTNESS=$(getBrightness)
|
||||
NEWBRIGHTNESS=$((${MYBRIGHTNESS}-${STEP}))
|
||||
if (( ${NEWBRIGHTNESS} < ${MIN} ))
|
||||
then
|
||||
NEWBRIGHTNESS=${MIN}
|
||||
fi
|
||||
echo "${NEWBRIGHTNESS}" > /sys/class/backlight/${BRIGHTNESS_DEV}/brightness
|
||||
set_setting system.brightness ${NEWBRIGHTNESS}
|
||||
setBrightness ${NEWBRIGHTNESS}
|
||||
}
|
||||
getBrightness() {
|
||||
local BRIGHTNESS=$(cat /sys/class/backlight/${BRIGHTNESS_DEV}/brightness)
|
||||
return ${BRIGHTNESS}
|
||||
}
|
||||
|
||||
|
||||
case ${1} in
|
||||
"up")
|
||||
stepUp ${BRIGHTNESS}
|
||||
stepUp
|
||||
;;
|
||||
"down")
|
||||
stepDown ${BRIGHTNESS}
|
||||
stepDown
|
||||
;;
|
||||
"device")
|
||||
echo ${BRIGHTNESS_DEV}
|
||||
;;
|
||||
"path")
|
||||
echo ${BRIGHTNESS_PATH}
|
||||
;;
|
||||
"set")
|
||||
setBrightness "$(( ${STEP} * ${2} ))"
|
||||
;;
|
||||
*)
|
||||
getBrightness
|
||||
echo $?
|
||||
;;
|
||||
echo $(getBrightness)
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -135,7 +135,7 @@ case $1 in
|
|||
|
||||
BRIGHTNESS=$(get_setting system.brightness)
|
||||
log $0 "Restoring brightness to ${BRIGHTNESS}."
|
||||
echo ${BRIGHTNESS} >/sys/class/backlight/$(brightness device)/brightness
|
||||
brightness set ${BRIGHTNESS}
|
||||
quirks post
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -45,25 +45,30 @@ if [ "${1}" == "setaudio" ];then
|
|||
fi
|
||||
|
||||
if [ "${1}" == "vol" ];then
|
||||
VOLSTEP=1
|
||||
if [ -n "${3}" ]; then
|
||||
VOLSTEP="${3}"
|
||||
CURRENTVOL=$(get_setting "audio.volume")
|
||||
MAXVOL=100
|
||||
MINVOL=0
|
||||
VOLSTEP=10
|
||||
|
||||
[ "$CURRENTVOL" -ge "$MAXVOL" ] && CURRENTVOL="$MAXVOL"
|
||||
[ "$CURRENTVOL" -le "$MINVOL" ] && CURRENTVOL="$MINVOL"
|
||||
|
||||
case ${2} in
|
||||
"+")
|
||||
STEPVOL=$(( $CURRENTVOL + $VOLSTEP ))
|
||||
;;
|
||||
"-")
|
||||
STEPVOL=$(( $CURRENTVOL - $VOLSTEP ))
|
||||
;;
|
||||
*)
|
||||
STEPVOL=${2}
|
||||
;;
|
||||
esac
|
||||
|
||||
[ "$STEPVOL" -ge "$MAXVOL" ] && STEPVOL="$MAXVOL"
|
||||
[ "$STEPVOL" -le "$MINVOL" ] && STEPVOL="$MINVOL"
|
||||
|
||||
amixer set "${DEVICE_AUDIO_MIXER}" ${STEPVOL}%
|
||||
alsactl store -f /storage/.config/asound.state
|
||||
set_setting "audio.volume" ${STEPVOL}
|
||||
fi
|
||||
|
||||
CURRENTVOL=$(get_setting "audio.volume")
|
||||
MAXVOL=100
|
||||
MINVOL=0
|
||||
if [ "${2}" == "+" ]; then
|
||||
STEPVOL=$(($CURRENTVOL+$VOLSTEP))
|
||||
elif [ "${2}" == "-" ]; then
|
||||
STEPVOL=$(($CURRENTVOL-$VOLSTEP))
|
||||
else
|
||||
STEPVOL=${2}
|
||||
fi
|
||||
[ "$STEPVOL" -ge "$MAXVOL" ] && STEPVOL="$MAXVOL"
|
||||
[ "$STEPVOL" -le "$MINVOL" ] && STEPVOL="$MINVOL"
|
||||
amixer -M set "${DEVICE_AUDIO_MIXER}" ${STEPVOL}%
|
||||
alsactl store -f /storage/.config/asound.state
|
||||
set_setting "audio.volume" ${STEPVOL}
|
||||
fi
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# Copyright (C) 2020-present Fewtarius
|
||||
|
||||
PKG_NAME="emulationstation"
|
||||
PKG_VERSION="92beed6"
|
||||
PKG_VERSION="4161d23"
|
||||
PKG_GIT_CLONE_BRANCH="main"
|
||||
PKG_REV="1"
|
||||
PKG_ARCH="any"
|
||||
|
|
Loading…
Reference in a new issue