From c548501d5246e41351d234091caaece86677d656 Mon Sep 17 00:00:00 2001 From: Tibo De Peuter Date: Fri, 25 Sep 2026 11:12:00 +0200 Subject: [PATCH] fix(hyprland): custom battery to avoid battery spam --- scripts/battery.sh | 21 +++++++++++++++++++++ stow/waybar/.config/waybar/modules.json | 8 +++++++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 scripts/battery.sh diff --git a/scripts/battery.sh b/scripts/battery.sh new file mode 100644 index 0000000..0ba93e5 --- /dev/null +++ b/scripts/battery.sh @@ -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}" diff --git a/stow/waybar/.config/waybar/modules.json b/stow/waybar/.config/waybar/modules.json index 683d70b..b0f0592 100644 --- a/stow/waybar/.config/waybar/modules.json +++ b/stow/waybar/.config/waybar/modules.json @@ -77,6 +77,12 @@ } }, + "custom/battery": { + "exec": "bash ${SCRIPT_DIR}/battery.sh", + "return-type": "json", + "interval": 60 + }, + "custom/control-center": { "format": "\uf085", /*  */ "tooltip": false @@ -263,7 +269,7 @@ "orientation": "inherit", "modules": [ /* Preview */ - "battery", + /* "battery", */ "custom/battery", /* Most-left */ "custom/system-shutdown", "custom/system-reboot",