diff --git a/modules/scripts/batterynotify.nix b/modules/scripts/batterynotify.nix index 3170ccb..dcf9b73 100644 --- a/modules/scripts/batterynotify.nix +++ b/modules/scripts/batterynotify.nix @@ -38,8 +38,8 @@ in # Runs full time in background x=0 while true; do - Battery_Status="$(cat /sys/class/power_supply/BAT*/status)" - Battery_Capacity=$(cat /sys/class/power_supply/BAT*/capacity) + Battery_Status="$(\cat /sys/class/power_supply/BAT*/status)" + Battery_Capacity=$(\cat /sys/class/power_supply/BAT*/capacity) case "$Battery_Status" in "Discharging") diff --git a/modules/scripts/batterywarning.nix b/modules/scripts/batterywarning.nix index 2e2a8f6..ecab48e 100644 --- a/modules/scripts/batterywarning.nix +++ b/modules/scripts/batterywarning.nix @@ -1,57 +1,48 @@ # taken and adapted https://github.com/miniMinn24/Battery_Notify with MIT License { - writeShellApplication, - mplayer, - brightnessctl, - ... +writeShellApplication, +mplayer, +brightnessctl, +... }: let - NotifySound = ../../assets/battery_notify.mp3; +NotifySound = ../../assets/battery_notify.mp3; in - writeShellApplication { - name = "custom-batterywarning"; - runtimeInputs = [ - mplayer - brightnessctl - ]; - text = '' +writeShellApplication { + name = "custom-batterywarning"; + runtimeInputs = [ + mplayer + brightnessctl + ]; + text = '' - # Delay for startup - sleep 5 + # Delay for startup + sleep 5 - # Change your sound path here - playsound() { - mplayer ${NotifySound} - } + playsound() { + mplayer ${NotifySound} + } - sendNotification() { - local message="$1" - notify-send -h string:x-canonical-private-synchronous:sys-notify -e -u critical "Battery Low!" "$message" - } - notify_count=0 - while true; do - Battery_Status="$(cat /sys/class/power_supply/BAT*/status)" - Battery_Capacity=$(cat /sys/class/power_supply/BAT*/capacity) + while true; do + Battery_Status="$(cat /sys/class/power_supply/BAT*/status)" + Battery_Capacity="$(cat /sys/class/power_supply/BAT*/capacity)" - if [ "$Battery_Status" == "Discharging" ] && [ "$Battery_Capacity" -le 14 ]; then - if [ "$notify_count" -eq 0 ]; then - sendNotification "Power running out: ''${Battery_Capacity}%" - playsound - notify_count=$((notify_count + 1)) - sleep 180 + if [ "$Battery_Status" == "Discharging" ]; then + if [ "$Battery_Capacity" -le 20 ] && [ "$Battery_Capacity" -ge 10 ]; then + notify-send -e -u critical "Battery Low!" "Power running out: ''${Battery_Capacity}%" + playsound + sleep 180 - elif [ "$notify_count" -eq 1 ]; then - sendNotification "Save your works before immediate shutdown." - playsound - notify_count=$((notify_count - 1)) - sleep 180 - fi - else - notify_count=0 - sleep 120 - fi - done - ''; - } + elif [ "$Battery_Capacity" -lt 10 ]; then + notify-send -e -u critical "Battery Low!" "Save your works before immediate shutdown." + playsound + sleep 180 + fi + else + sleep 120 + fi + done + ''; +} diff --git a/todo b/todo index ac5d55c..0330808 100644 --- a/todo +++ b/todo @@ -9,7 +9,6 @@ tor.x86_64 torbrowser-launcher.noarch maybe configure a bit ripgrep? majuscules -the battery notification is broken why frameworktooltui settings dont apply?