From 420ceb49b53a8fa9d8ba8443e42e50cd7bd7cea9 Mon Sep 17 00:00:00 2001 From: Philip Wittamore Date: Sun, 12 Jul 2026 11:08:50 +0200 Subject: update --- articles/2025/Modified-dwm-bar-battery-script.html | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100755 articles/2025/Modified-dwm-bar-battery-script.html (limited to 'articles/2025/Modified-dwm-bar-battery-script.html') diff --git a/articles/2025/Modified-dwm-bar-battery-script.html b/articles/2025/Modified-dwm-bar-battery-script.html new file mode 100755 index 0000000..b837c73 --- /dev/null +++ b/articles/2025/Modified-dwm-bar-battery-script.html @@ -0,0 +1,80 @@ + + + + + + + Modified dwm-bar battery script + + +
+

Bloggings

+ Back + +
+ +
+
+

Modified dwm-bar battery script

+

2025-04-23

+

adding battery charging nerdfont icons

+

This is a modification of the default dwm-battery script

+

+
+#!/bin/sh
+
+# A dwm_bar function to read the battery level and status
+# GNU GPLv3
+
+dwm_battery () {
+    # Change BAT1 to whatever your battery is identified as. Typically BAT0 or BAT1
+    CHARGE=$(cat /sys/class/power_supply/BAT0/capacity)
+    STATUS=$(cat /sys/class/power_supply/BAT0/status)
+
+    #printf "%s" "$SEP1"
+    printf " %s"
+    if [ "$IDENTIFIER" = "unicode" ]; then
+        if [ "$STATUS" = "Charging" ]; then
+           if   [ "${CHARGE}" -lt 10 ];  then ICON="󱃍󱐋"
+           elif [ "${CHARGE}" -lt 20 ];  then ICON="󰁺󱐋"
+           elif [ "${CHARGE}" -lt 30 ];  then ICON="󰁻󱐋"
+           elif [ "${CHARGE}" -lt 40 ];  then ICON="󰁼󱐋"
+           elif [ "${CHARGE}" -lt 50 ];  then ICON="󰁽󱐋"
+           elif [ "${CHARGE}" -lt 60 ];  then ICON="󰁾󱐋"
+           elif [ "${CHARGE}" -lt 70 ];  then ICON="󰁿󱐋"
+           elif [ "${CHARGE}" -lt 80 ];  then ICON="󰂀󱐋"
+           elif [ "${CHARGE}" -lt 90 ];  then ICON="󰂂󱐋"
+           elif [ "${CHARGE}" -lt 100 ]; then ICON="󰁹󱐋"
+           fi
+        else
+           if   [ "${CHARGE}" -lt 10 ];  then ICON="󱃍"
+           elif [ "${CHARGE}" -lt 20 ];  then ICON="󰁺"
+           elif [ "${CHARGE}" -lt 30 ];  then ICON="󰁻"
+           elif [ "${CHARGE}" -lt 40 ];  then ICON="󰁼"
+           elif [ "${CHARGE}" -lt 50 ];  then ICON="󰁽"
+           elif [ "${CHARGE}" -lt 60 ];  then ICON="󰁾"
+           elif [ "${CHARGE}" -lt 70 ];  then ICON="󰁿"
+           elif [ "${CHARGE}" -lt 80 ];  then ICON="󰂀"
+           elif [ "${CHARGE}" -lt 90 ];  then ICON="󰂂"
+           elif [ "${CHARGE}" -lt 100 ]; then ICON="󰁹"
+           fi
+        fi
+        printf "%s %s%% " "$ICON" "$CHARGE"
+    else
+        printf "BAT %s%% %s" "$CHARGE" "$STATUS"
+    fi
+    #printf "%s\n" "$SEP2"
+}
+
+dwm_battery
+
+
+
+ + + -- cgit v1.3.1