aboutsummaryrefslogtreecommitdiff
path: root/articles/2025/Modified-dwm-bar-battery-script.html
diff options
context:
space:
mode:
Diffstat (limited to 'articles/2025/Modified-dwm-bar-battery-script.html')
-rwxr-xr-xarticles/2025/Modified-dwm-bar-battery-script.html80
1 files changed, 80 insertions, 0 deletions
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 @@
+<!doctype html>
+<html lang="EN">
+ <head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="stylesheet" href="/style.css">
+ <title>Modified dwm-bar battery script</title>
+ </head>
+ <body>
+ <header>
+ <h1>Bloggings</h1>
+ <a href="/index.php">Back</a>
+
+ </header>
+
+<main>
+<article>
+<h2>Modified dwm-bar battery script</h2>
+<h3>2025-04-23</h3>
+<h4>adding battery charging nerdfont icons</h4>
+<p>This is a modification of the default dwm-battery script</p>
+<p><img src="/images/blog/dwm_bar.png"></p>
+<pre>
+#!/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
+</pre>
+</article>
+</main>
+<footer>
+
+<p>&nbsp;</p>
+
+<p>§</p>
+ </footer>
+</body>
+</html>