diff options
| author | Andrew <saintruler@gmail.com> | 2020-06-07 17:45:29 +0400 |
|---|---|---|
| committer | Andrew <saintruler@gmail.com> | 2020-06-07 17:45:29 +0400 |
| commit | 19671469e2d7c3044be00f8ef5ee305b18a3912c (patch) | |
| tree | bc6602f2bf23749613573e6d794348313c1255f6 /.local/bin | |
| parent | 4b43dedb78c7a0b956015c833e96460ffe1fd18c (diff) | |
added battery script
Diffstat (limited to '.local/bin')
| -rwxr-xr-x | .local/bin/statusbar/battery | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/.local/bin/statusbar/battery b/.local/bin/statusbar/battery new file mode 100755 index 0000000..e125a6c --- /dev/null +++ b/.local/bin/statusbar/battery @@ -0,0 +1,13 @@ +#!/bin/sh +for battery in /sys/class/power_supply/BAT? +do + # Get its remaining capacity and charge status. + capacity=$(cat "$battery"/capacity) || break + status=$(sed "s/[Dd]ischarging/🔋/;s/[Nn]ot charging/🛑/;s/[Cc]harging/🔌/;s/[Uu]nknown/♻️/;s/[Ff]ull/⚡/" "$battery"/status) + + # If it is discharging and 25% or less, we will add a ❗ as a warning. + [ "$capacity" -le 25 ] && [ "$status" = "🔋" ] && warn="❗" + + printf "%s%s%s%% " "$status" "$warn" "$capacity" + unset warn +done | sed 's/ *$//' |