commit 6db26339e9fc7379bc47cdb56cf64925f6d06e58
parent adb239ef3c116102ba505c71f653c86f30651f60
Author: pyratebeard <root@pyratebeard.net>
Date: Sat, 9 Nov 2019 17:17:50 +0000
display current battery status
passing the '-c' flag now shows the current battery status and exits. updated README with details
Diffstat:
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
@@ -15,3 +15,8 @@ A simple battery level notifier
systemctl --user enable battery-notify
systemctl --user start battery-notify
```
+
+You can show the current battery status by passing the `-c` flag
+```
+check-batt -c
+```
diff --git a/check-batt b/check-batt
@@ -1,12 +1,13 @@
#!/usr/bin/env bash
-BAT_NUM='1'
+BAT_NUM='0'
STATUS_FILE=/tmp/check-bat.tmp
BATTPERC=$(cat /sys/class/power_supply/BAT${BAT_NUM}/capacity)
BATTSTATUS=$(cat /sys/class/power_supply/BAT${BAT_NUM}/status)
LAST_STATUS=''
LAST_NOTIF_LEVEL=0
NOTIF_LEVEL=0
+CHECK="N"
if [ -e $STATUS_FILE ] ; then
. $STATUS_FILE
@@ -24,6 +25,17 @@ notify() {
DISPLAY=:0 /usr/bin/notify-send -t 3500 -u "$level" "POWER" "$msg"
}
+while getopts "c" arg ; do
+ case "$arg" in
+ c) CHECK="Y" ;;
+ esac
+done
+
+if [[ "$CHECK" == "Y" ]] ; then
+ notify "normal" "battery is now $BATTSTATUS, Capacity: $BATTPERC"
+ exit
+fi
+
# Battery status changed
if [[ "$BATTSTATUS" != "$LAST_STATUS" ]] ; then
notify "normal" "battery is now $BATTSTATUS, Capacity: $BATTPERC"