Commit Diff


commit - a02d4cb012440dfd4d4e6226b6ca1968ae472d09
commit + 1a3ca3fc8f60680458e2eb19a2986ddcd768f30f
blob - /dev/null
blob + 0a957b06b7b3f96ef8961779679a4bff588c7697 (mode 755)
--- /dev/null
+++ openbsd_i3_battery.sh
@@ -0,0 +1,38 @@
+# !/bin/sh
+
+LIMIT_PERCENT=20
+SLEEP_SECONDS=300
+SOUND_TO_PLAY=""
+
+while getopts "l:t:s:" name; do
+    case $name in 
+        l) LIMIT_PERCENT="$OPTARG" ;;
+        t) SLEEP_SECONDS="$OPTARG" ;;
+        s) SOUND_TO_PLAY="$OPTARG" ;;
+        ?)
+            echo "Usage: ./openbsd_i3_battery.sh [-l LIMIT_PERCENT] [-t SLEEP_SECONDS] [-s SOUND_TO_PLAY]"; exit 2 ;;
+    esac
+done
+
+echo "LIMIT_PERCENT=$LIMIT_PERCENT"
+echo "SLEEP_SECONDS=$SLEEP_SECONDS"
+echo "SOUND_TO_PLAY=$SOUND_TO_PLAY"
+
+while true; do
+    AC_STATUS=$(apm -a)
+    BATTERY_PERCENT=$(apm -l)
+    MESSAGE=$(apm | head -1)
+    if [ $AC_STATUS -eq "0" ]
+    then
+        if [ $BATTERY_PERCENT -lt $LIMIT_PERCENT ]
+        then
+            i3-nagbar -m "$MESSAGE" &
+            if [ "$SOUND_TO_PLAY" ]
+            then
+                aucat -i "$SOUND_TO_PLAY"
+            fi
+        fi
+    fi
+    echo "tick"
+    sleep $SLEEP_SECONDS
+done
blob - /dev/null
blob + ade6c7503924a559746cfd1c15cad19792a0d8fd (mode 644)
Binary files /dev/null and openbsd_i3_battery.wav differ