#! @execline@/bin/execlineb loopwhilex elglob -0 bats /sys/class/power_supply/BAT* # We need to capture the whole status line, and then echo it all at # once, to work around https://github.com/swaywm/sway/issues/3857. backtick -i -n line { foreground { forx bat { $bats } importas -i -u bat bat foreground { backtick -i -n status { cat ${bat}/status } importas -i -u status status ifelse { test $status = Charging } { printf "↑" } if { test $status = Discharging } printf "↓" } foreground { redirfd -r 0 ${bat}/capacity tr -d "\n" } foreground { printf "%% " } } foreground { date "+%Y-%m-%d %H:%M:%S" } } importas -i -u line line if { echo $line } sleep 1