#!/bin/sh
# see sway-bar(5) and swaybar-protocol(7)
-MEGA=1000
+KILO=1000
printf '{ "version": 1 }\n[\n'
while true; do
printf ' [\n'
- printf ' {"full_text": "%s"},\n' "$(ip -4 addr show scope global | grep -oP '(?<=inet\s)\d+(\.\d+){3}')"
- printf ' {"full_text": "%d° C"},\n' $(calc "$(cat /sys/class/thermal/thermal_zone0/temp) // ${MEGA}") # thermal_zone0 is what ACPI's interested in, so probably a fair choice among the many alternatives
- printf ' {"full_text": "%s"},\n' "$(date +'%Y-%m-%d %H:%M:%S/%Z')"
+ printf ' {"separator_block_width": 20, "full_text": "%s"},\n' "$(ip -4 addr show scope global | grep -oP '(?<=inet\s)\d+(\.\d+){3}')"
+ printf ' {"separator_block_width": 20, "full_text": "%s"},\n' "$(cat /sys/class/power_supply/BAT0/status)"
+ printf ' {"separator_block_width": 20, "full_text": "%d° C"},\n' $(calc "$(cat /sys/class/thermal/thermal_zone0/temp) // ${KILO}")
+ printf ' {"separator_block_width": 20, "full_text": "%s"},\n' "$(date +'%Y-%m-%d %H:%M:%S/%Z')"
printf ' ],\n'
sleep 1
done