41 lines
927 B
Bash
Executable File
41 lines
927 B
Bash
Executable File
#!/bin/bash
|
|
clear
|
|
get_term_size() {
|
|
IFS='[;' read -sp $'\e7\e[9999;9999H\e[6n\e8' -d R -rs _ lines
|
|
}
|
|
listNodes() {
|
|
for nodeList in $(bspc query -N -n .window | grep -v "$(bspc query -N -n)"); do
|
|
echo $(xtitle -t 90 ${nodeList})
|
|
done
|
|
}
|
|
getNodes() {
|
|
count=0
|
|
for nodeCount in $(bspc query -N -n .window | grep -v "$(bspc query -N -n)"); do
|
|
count=$((count+1))
|
|
export node${count}=$nodeCount
|
|
done
|
|
selectedNode="node$y"
|
|
}
|
|
getCursorPos() {
|
|
echo -en "\E[6n" && read -sdR CURPOS && CURPOS=${CURPOS#*[} && y=$(printf ";"$CURPOS | cut -d';' -f2)
|
|
}
|
|
listNodes
|
|
printf '\e[H'
|
|
while [[ true ]]; do
|
|
read -rsn1 input
|
|
getCursorPos
|
|
getNodes
|
|
if [[ "$input" = "j" && $y -lt $count ]]; then
|
|
printf '\e[B'
|
|
elif [[ "$input" = "k" ]]; then
|
|
printf '\e[A'
|
|
elif [[ "$input" = "l" ]]; then
|
|
bspc node --focus ${!selectedNode}
|
|
clear
|
|
break
|
|
elif [[ "$input" = "q" ]]; then
|
|
clear
|
|
break
|
|
fi
|
|
done
|