Show battery power draw from sensors in waybar

Replace the built-in battery module with a custom/battery script that
combines sysfs capacity/status with the power1 reading from `sensors`,
displaying it as "85% (5.4W)" next to the icon.
This commit is contained in:
2026-08-22 13:43:19 +00:00
parent 3d3717d0fb
commit 9170828b36
3 changed files with 46 additions and 5 deletions
+2 -2
View File
@@ -5,7 +5,7 @@
"spacing": 6,
"modules-left": ["sway/workspaces", "sway/mode"],
"modules-center": ["clock"],
"modules-right": ["cpu", "memory", "custom/network", "pulseaudio", "backlight", "battery", "tray", "custom/power"],
"modules-right": ["cpu", "memory", "custom/network", "pulseaudio", "backlight", "custom/battery", "tray", "custom/power"],
"sway/workspaces": {
"disable-scroll": false,
"all-outputs": false,
@@ -17,7 +17,7 @@
"custom/network": { "exec": "~/.config/waybar/scripts/network-cycle.sh", "return-type": "json", "interval": 300, "signal": 8, "on-click": "~/.config/waybar/scripts/network-cycle.sh next", "on-click-right": "~/.config/waybar/scripts/network-cycle.sh copy" },
"pulseaudio": { "format": "{icon} {volume}%", "format-muted": "󰝟 muted", "format-icons": ["󰕿", "󰖀", "󰕾"], "tooltip-format": "{desc}", "on-click": "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle", "on-click-right": "~/.config/waybar/scripts/audio-output-cycle.sh" },
"backlight": { "format": "󰃠 {percent}%" },
"battery": { "states": { "warning": 30, "critical": 15 }, "format": "{icon} {capacity}%", "format-charging": "󰂄 {capacity}%", "format-icons": ["󰁺", "󰁼", "󰁾", "󰂀", "󰁹"] },
"custom/battery": { "exec": "~/.config/waybar/scripts/battery-power.sh", "return-type": "json", "interval": 10, "tooltip": true },
"tray": { "spacing": 8 },
"custom/power": {
"format": "󰐥",