fix(hyprland): custom battery to avoid battery spam

This commit is contained in:
Tibo De Peuter 2026-09-25 11:12:00 +02:00
parent 0fff8294a7
commit c548501d52
No known key found for this signature in database
GPG key ID: 9187B5FA0F4B6F6D
2 changed files with 28 additions and 1 deletions

21
scripts/battery.sh Normal file
View file

@ -0,0 +1,21 @@
#!/usr/bin/env bash
capacity="$(cat /sys/class/power_supply/BAT0/capacity)"
status="$(cat /sys/class/power_supply/BAT0/status)"
if [ "${status}" = "Charging" ]; then
icon="\ue55b"
elif [ "${capacity}" -ge 90 ]; then
icon="\uf240"
elif [ "${capacity}" -ge 75 ]; then
icon="\uf241"
elif [ "${capacity}" -ge 50 ]; then
icon="\uf242"
elif [ "${capacity}" -ge 25 ]; then
icon="\uf243"
else
icon="\uf244"
fi
printf '{"text": "%s%% %s", "tooltip": "Status: %s", "class": "%s"}\n' \
"${capacity}" "${icon}" "${status}" "${status}"

View file

@ -77,6 +77,12 @@
} }
}, },
"custom/battery": {
"exec": "bash ${SCRIPT_DIR}/battery.sh",
"return-type": "json",
"interval": 60
},
"custom/control-center": { "custom/control-center": {
"format": "\uf085", /* */ "format": "\uf085", /* */
"tooltip": false "tooltip": false
@ -263,7 +269,7 @@
"orientation": "inherit", "orientation": "inherit",
"modules": [ "modules": [
/* Preview */ /* Preview */
"battery", /* "battery", */ "custom/battery",
/* Most-left */ /* Most-left */
"custom/system-shutdown", "custom/system-shutdown",
"custom/system-reboot", "custom/system-reboot",