1
0
Fork 0

update scripts

main
urosm 2024-04-11 23:23:29 +02:00
parent eba5740da8
commit d22ecb22bb
1 changed files with 59 additions and 10 deletions

View File

@ -2,14 +2,63 @@
printf "{\"version\":1}\n" printf "{\"version\":1}\n"
printf "[\n" printf "[\n"
while true
do if ! command -v jq >/dev/null; then
printf [ while true; do
swaymsg -t get_inputs | jq -Mcj '[.[] | select(.type=="keyboard")][0] | {"full_text":.xkb_active_layout_name,"urgent":.xkb_active_layout_index}, ","' printf '[{
cat /sys/class/power_supply/BAT0/capacity | jq -Mcj 'if .<20 then {"full_text":.,"urgent":true} else {"full_text":.} end, ","' "full_text":" jq: command not found ",
date +%c | jq -RMcj '{"full_text":.}, ","' "urgent":true,
swaymsg -t get_tree | jq -Mcj '.nodes[] | select(.name=="__i3").nodes[] | select(.name=="__i3_scratch").floating_nodes | {"full_text":length,"urgent":length}, ","' "separator_block_width":0
makoctl list | jq -Mcj '.data[] | if length>0 then {"full_text":([length, .[0].summary.data] | join(": ")),"urgent":(.[0].urgency.data == 2)}, "," else "" end' },],'
printf ], sleep 1
timeout 1 swaymsg -t subscribe '["input","binding"]' >/dev/null done
fi
while true; do
printf "["
# keyboard layout
swaymsg -t get_inputs | jq -Mcj '
[.[] | select(.type=="keyboard")][0]
| {
"full_text":([" ",.xkb_active_layout_name," "]|join("")),
"urgent":.xkb_active_layout_index,
"separator_block_width":0
}, ","'
# battery
# shellcheck disable=SC2002
cat /sys/class/power_supply/BAT0/capacity | jq -Mcj '
if .<20 then {
"full_text":([" ",.," % "]|join("")),
"urgent":true,
"separator_block_width":0
} else {
"full_text":([" ",.," % "]|join("")),
"separator_block_width":0
} end, ","'
# date
date +%c | jq -RMcj '{
"full_text":([" ",.," "]|join("")),
"separator_block_width":0
}, ","'
# scratchpad
swaymsg -t get_tree | jq -Mcj '
.nodes[]
| select(.name=="__i3").nodes[]
| select(.name=="__i3_scratch").floating_nodes
| if length>0 then {
"full_text":([" ",length," "]|join("")),
"urgent":true,
"separator_block_width":0
}, "," else "" end'
# notifications
makoctl list | jq -Mcj '
.data[]
| if length>0 then {
"full_text":([" (",length,") ",.[0].summary.data," "]|join("")),
"urgent":(.[0].urgency.data==2),
"separator_block_width":0
}, "," else "" end'
printf "],"
# timeout
timeout 1 swaymsg -t subscribe '["input","binding"]' >/dev/null
done done