Skip to content

Commit

Permalink
suspend at a level
Browse files Browse the repository at this point in the history
suspend to ram when a certain level is reached
  • Loading branch information
Hephaestus14089 committed May 6, 2023
1 parent 3c5fd88 commit 1a04472
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions power-notify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ start_listener() {
battery_level=$(cat /sys/class/power_supply/BAT0/capacity)
battery_status=$(cat /sys/class/power_supply/BAT0/status)

# suspend to RAM
if [[ "$battery_status" == "Discharging" && "$battery_level" -le "$suspend_limit" ]]; then
loginctl suspend
fi

if [[ "$battery_status" == "Charging" && "$battery_level" -ge "$upper_limit" ]]; then
notify-send -t 3000 "Battery Full" "Level: ${battery_level}%"
elif [[ "$battery_status" == "Discharging" && "$battery_level" -le "$lower_limit" ]]; then
Expand All @@ -48,5 +53,7 @@ start_listener() {
lower_limit="$1"
upper_limit="$2"

suspend_limit=5

check_args "$@"
start_listener

0 comments on commit 1a04472

Please sign in to comment.