Added sways xprop replacement script.
This commit is contained in:
parent
f396cb08cb
commit
30bcf55790
25
.config/wm_scripts/sway-winprops.sh
Executable file
25
.config/wm_scripts/sway-winprops.sh
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Implementation of alternative to xprop for sway.
|
||||||
|
# Requires:
|
||||||
|
# - slurp
|
||||||
|
# - swaymsg
|
||||||
|
# - jq
|
||||||
|
|
||||||
|
# Get window information and store into parallel arrays.
|
||||||
|
WINDOWS=$(swaymsg -t get_tree | jq '.. | select(.pid? and .visible?)')
|
||||||
|
PIDS=($(echo $WINDOWS | jq '.pid'))
|
||||||
|
# readarray needed to handle whitespaced names.
|
||||||
|
readarray -t NAMES < <(echo $WINDOWS | jq '.name')
|
||||||
|
readarray -t GEOM < <(echo $WINDOWS | jq -r '.rect | "\(.x),\(.y) \(.width)x\(.height)"')
|
||||||
|
|
||||||
|
length=${#PIDS[@]}
|
||||||
|
array=()
|
||||||
|
for (( i=0 ; i<${length} ; i++ )); do
|
||||||
|
array[$i]="${GEOM[$i]} $i"
|
||||||
|
done
|
||||||
|
|
||||||
|
selected_index=$(printf "%s\n" "${array[@]}" | slurp -f "%l") || exit 1
|
||||||
|
PID="${PIDS[$selected_index]}"
|
||||||
|
NAME="${NAMES[$selected_index]}"
|
||||||
|
echo $WINDOWS | jq "select(.pid == $PID and .name == $NAME)"
|
Loading…
Reference in New Issue
Block a user