From 33cf649f2d0f7a57c7a66250fa12aa5e9ce759b5 Mon Sep 17 00:00:00 2001 From: Jake VanderVaate Date: Mon, 28 Feb 2022 22:12:51 -0600 Subject: initial commit, added status bar scripts --- battery-notify | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 battery-notify (limited to 'battery-notify') diff --git a/battery-notify b/battery-notify new file mode 100755 index 0000000..50099d7 --- /dev/null +++ b/battery-notify @@ -0,0 +1,36 @@ +#!/bin/sh + +lock_command="slock" + +while true; do + +bat_0="$(cat /sys/class/power_supply/BAT0/capacity)" +bat_1="$(cat /sys/class/power_supply/BAT1/capacity)" +bats_total=$((bat_0+bat_1)) +bats_average=$((bats_total/2)) + +if [ "$bats_average" = "99" ] +then + : +elif [ "$bats_average" = "25" ] +then + notify-send "Battery" "Battery charge is $bats_average\%" +elif [ "$bats_average" = "15" ] +then + notify-send -u critical "Battery-Notify" "Battery charge is $bats_average\%\nPlug in immediately" +elif [ "$bats_average" = "5" ] +then + notify-send "Battery-Notify" "Laptop will hibernate in 1 minute" + sleep 60 + if [ "$(cat /sys/class/power_supply/BAT0/status)" = "Not charging" ] + then + "$lock_command" + else + : + fi +else + : +fi + +sleep 180 +done -- cgit v1.2.1