#!/bin/bash # Read instantaneous power draw from the battery's power_now sysfs node. # The glob BAT* handles different battery names (BAT0, BAT1, etc.). # power_now is in microwatts; dividing by 1 000 000 converts to watts. if [ -f /sys/class/power_supply/BAT*/power_now ]; then powerDraw="󰠰 $(($(cat /sys/class/power_supply/BAT*/power_now)/1000000))w" fi # Emit a Waybar JSON payload; text and tooltip both show the wattage (or empty string on desktop). cat << EOF { "text":"$powerDraw", "tooltip":"power Draw $powerDraw"} EOF