#!/bin/bash # mark this file as executable, # then change your sway config (.config/sway/): # # [...] # bar { # [...] # # # When the status_command prints a new line to stdout, swaybar updates. # status_command ~/.config/sway/swaystatus_mark # # [...] # } # [...] while true; do Extra="" # ExtraUsers="$(ps -e -o user=-------------------- | grep -E '^d26r.?_' | sed -Ee 's/d26r.?_(.*)/\1, /g' | sort -u)" ; Extra+="$(echo "$ExtraUsers" | grep -vE '^temp_[0-9]+, $' | xargs -d '\n' printf '%s')+$(echo "$ExtraUsers" | grep -cE '^temp_[0-9]+, $') | " BatteryStatus="$(upower -i /org/freedesktop/UPower/devices/battery_BAT0)" Perc="$(echo "$BatteryStatus" | grep -i 'percentage' | grep -ioE '\-?[01-9,.]+%')" Watt="$(echo "$BatteryStatus" | grep -i 'energy-rate' | grep -ioE '\-?[01-9,.]+ ?W' | grep -ioE '\-?[01-9]+' | head -n 1)" Remaining="$(echo "$BatteryStatus" | grep -i 'time to empty' | grep -ioE '\-?[01-9,.]+.*')" Time="$(date +'%H:%M:%S | %F')" printf '%s%s, %sW → %s | %s \n' "$Extra" "$Perc" "$Watt" "$Remaining" "$Time" snooze -H '*' -M '*' -S '/5' || sleep 5 done