1
0
Fork 0
dot/.local/bin/status.sh

50 lines
1.4 KiB
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 -Mcj '.data[] |
if length>0 then {
"full_text":(["(",length,") ",.[0].summary.data]|join("")),
"urgent":(.[0].urgency.data==2),
} else {
"full_text":"(0)",
} end, ","'
# keyboard layout
swaymsg -t get_inputs | jq -Mcj '[.[] | select(.type=="keyboard")][0] | {
"full_text":.xkb_active_layout_name,
"urgent":.xkb_active_layout_index,
}, ","'
# battery
# shellcheck disable=SC2002
cat /sys/class/power_supply/BAT0/capacity | jq -Mcj '
if .<20 then {
"full_text":([.," %"]|join("")),
"urgent":true,
} else {
"full_text":([.," %"]|join("")),
} end, ","'
# date
date +%c | jq -RMcj '{ "full_text":., }, ","'
# scratchpad
swaymsg -t get_tree | jq -Mcj '.nodes[] | select(.name=="__i3").nodes[] |
select(.name=="__i3_scratch").floating_nodes | {
"full_text":length,
"urgent":length,
}, ","'
printf "],"
# timeout
timeout 1 swaymsg -t subscribe '["input","binding"]' >/dev/null
sleep 0.1
done