1
0
Fork 0
dot/.local/bin/swaystatus

29 lines
840 B
Bash
Executable File

#!/bin/sh
printf "{\"version\":1}\n"
printf "[\n"
if ! command -v jq >/dev/null; then
while :; do
printf '[{"full_text":"jq: command not found","urgent":true},],'
sleep 60
done
fi
while :; do
printf "["
# notifications
makoctl list | jq -cj '.data[][0] | {"full_text":.summary.data,"urgent":(.urgency.data==2)}, ","'
# battery
# shellcheck disable=SC2002
cat /sys/class/power_supply/BAT0/capacity | jq -cj '{"full_text":((.|tostring)+" %"),"urgent":(.<20)}, ","'
# date
date | jq -Rcj '{"full_text":.}, ","'
# scratchpad
swaymsg -t get_tree | jq -cj 'recurse(.nodes[]) | select(.name=="__i3_scratch").floating_nodes | {"full_text":length,"urgent":length}, ","'
printf "],"
# timeout
timeout 0.9 swaymsg -qt subscribe '["binding"]' >/dev/null
sleep 0.1
done