blob: b837c732027a5977e553f7d4a11c1123e14731c0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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> </p>
<p>§</p>
</footer>
</body>
</html>
|