diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2021-08-19 12:42:52 +0200 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2021-08-19 12:42:52 +0200 |
| commit | 7d9345c9564370bdb32cbb06d24b238986572ea6 (patch) | |
| tree | e9690847f8dca5dccfb759dd53b5b7895eb87872 /local/bin | |
| parent | f064922a74100af86def550d4ef6a50ab4e80203 (diff) | |
| download | dotfiles-7d9345c9564370bdb32cbb06d24b238986572ea6.tar.gz dotfiles-7d9345c9564370bdb32cbb06d24b238986572ea6.tar.bz2 dotfiles-7d9345c9564370bdb32cbb06d24b238986572ea6.zip | |
Added battery-low-notify script and crontab to run it every 10min
Diffstat (limited to 'local/bin')
| -rwxr-xr-x | local/bin/battery-low-check | 5 | ||||
| -rwxr-xr-x | local/bin/battery-low-notify | 14 |
2 files changed, 14 insertions, 5 deletions
diff --git a/local/bin/battery-low-check b/local/bin/battery-low-check deleted file mode 100755 index dbbdc6b..0000000 --- a/local/bin/battery-low-check +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -capacity=$(cat /sys/class/power_supply/BAT0/capacity) - -[ "$capacity" -lt 10 ] && notify-send -u critical "Battery low $capacity%" diff --git a/local/bin/battery-low-notify b/local/bin/battery-low-notify new file mode 100755 index 0000000..605ea91 --- /dev/null +++ b/local/bin/battery-low-notify @@ -0,0 +1,14 @@ +#!/bin/sh + +battery_dir='/sys/class/power_supply/BAT0' + +[ ! -d "$battery_dir" ] && exit 1 + +if [ "$(cat "$battery_dir/status")" != 'Charging' ] +then + capacity="$(cat "$battery_dir/capacity")" + [ "$capacity" -lt 15 ] && + notify-send -u critical "Battery low: $capacity%" +fi + +exit 0 |
