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

50 lines
1.4 KiB
Bash
Raw Normal View History

2024-02-04 16:24:33 +01:00
#!/bin/sh
printf "{\"version\":1}\n"
printf "[\n"
2024-04-11 23:23:29 +02:00
if ! command -v jq >/dev/null; then
2024-07-07 22:10:54 +02:00
while :; do
2024-05-05 17:35:59 +02:00
printf '[{ "full_text":"jq: command not found", "urgent":true },],'
2024-07-07 22:10:54 +02:00
sleep 60
2024-04-11 23:23:29 +02:00
done
fi
2024-07-07 22:10:54 +02:00
while :; do
2024-04-11 23:23:29 +02:00
printf "["
# keyboard layout
2024-07-07 22:10:54 +02:00
swaymsg -t get_inputs | jq -Mcj '[.[] | select(.type=="keyboard")][0] | {
2024-05-05 17:35:59 +02:00
"full_text":.xkb_active_layout_name,
2024-04-11 23:23:29 +02:00
"urgent":.xkb_active_layout_index,
}, ","'
# battery
# shellcheck disable=SC2002
cat /sys/class/power_supply/BAT0/capacity | jq -Mcj '
2024-07-07 22:10:54 +02:00
if .<20 then {
2024-05-05 17:35:59 +02:00
"full_text":([.," %"]|join("")),
"urgent":true,
2024-07-07 22:10:54 +02:00
} else {
2024-05-05 17:35:59 +02:00
"full_text":([.," %"]|join("")),
2024-07-07 22:10:54 +02:00
} end, ","'
2024-04-11 23:23:29 +02:00
# date
2024-05-05 17:35:59 +02:00
date +%c | jq -RMcj '{ "full_text":., }, ","'
2024-04-11 23:23:29 +02:00
# scratchpad
2024-05-05 17:35:59 +02:00
swaymsg -t get_tree | jq -Mcj '.nodes[] | select(.name=="__i3").nodes[] |
2024-07-07 22:10:54 +02:00
select(.name=="__i3_scratch").floating_nodes | {
2024-06-12 00:49:03 +02:00
"full_text":length,
"urgent":length,
}, ","'
2024-04-11 23:23:29 +02:00
# notifications
2024-06-12 00:49:03 +02:00
makoctl list | jq -Mcj '.data[] |
if length>0 then {
"full_text":(["(",length,") ",.[0].summary.data]|join("")),
"urgent":(.[0].urgency.data==2),
} else {
2024-07-07 22:10:54 +02:00
"full_text":"(0)",
2024-06-12 00:49:03 +02:00
} end, ","'
2024-04-11 23:23:29 +02:00
printf "],"
# timeout
timeout 1 swaymsg -t subscribe '["input","binding"]' >/dev/null
2024-07-07 22:10:54 +02:00
sleep 0.02
2024-02-04 16:24:33 +01:00
done