From 5b04cdee94aab90df1982a85dc621cd6a256da1f Mon Sep 17 00:00:00 2001 From: fewtarius Date: Fri, 2 Feb 2024 17:02:42 +0000 Subject: [PATCH] Corrects issues with flashing the LED when the battery is low. --- packages/jelos/sources/scripts/led_flash | 36 ++++++++++++++----- .../sysutils/powerstate/sources/powerstate.sh | 6 ++-- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/packages/jelos/sources/scripts/led_flash b/packages/jelos/sources/scripts/led_flash index 3bae90477..660e20001 100755 --- a/packages/jelos/sources/scripts/led_flash +++ b/packages/jelos/sources/scripts/led_flash @@ -7,16 +7,36 @@ COLOR=$(get_setting led.color) BRI=$(get_setting led.brightness) -ledcontrol off -ledcontrol brightness mid +if [ -z "${COLOR}" ] || \ + [ "${COLOR}" = "off" ] || \ + [ -n "${DEVICE_LED_CHARGING}" ] +then + FLASH_COLOR="red" +else + FLASH_COLOR="${COLOR}" +fi + +if [ "${DEVICE_LED_BRIGHTNESS}" = "true" ] +then + ledcontrol brightness mid +fi for i in $(seq 1 1 3) do - sleep 1 - ledcontrol ${1} - sleep 1 - ledcontrol off + ledcontrol ${FLASH_COLOR} + sleep .5 + ledcontrol poweroff + sleep .5 done -ledcontrol ${COLOR} -ledcontrol brightness ${BRI} +if [ -n "${COLOR}" ] +then + ledcontrol ${COLOR} +else + ledcontrol default +fi + +if [ "${DEVICE_LED_BRIGHTNESS}" = "true" ] +then + ledcontrol brightness ${BRI} +fi diff --git a/packages/sysutils/powerstate/sources/powerstate.sh b/packages/sysutils/powerstate/sources/powerstate.sh index e28605db5..0881934d3 100755 --- a/packages/sysutils/powerstate/sources/powerstate.sh +++ b/packages/sysutils/powerstate/sources/powerstate.sh @@ -71,8 +71,8 @@ do fi ### Until we have an overlay. :rofl: BATLEFT=$(battery_percent) - if (( "${BATCNT}" >= "90" )) && - [[ "${STATUS}" =~ Disch ]] + if (( "${BATCNT}" >= "20" )) && + [[ "${AC_STATUS}" =~ Disch ]] then AUDIBLEALERT=$(get_setting system.battery.warning) if (( ${BATLEFT} < "26" )) @@ -80,7 +80,7 @@ do if [ "${DEVICE_LED_CONTROL}" = "true" ] then # Flash the RGB or power LED if available. - led_flash red + led_flash BATCNT=0 elif [ "${AUDIBLEALERT}" = "1" ] then