2022-03-14 19:21:46 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
ALL_NODES='recurse(.nodes[]?, .floating_nodes[]?) | select(.pid and .visible)'
|
|
|
|
WINDOW_NAME='(.app_id // .window_properties.class)'
|
|
|
|
ID_PREFIX='"\(.pid):"'
|
|
|
|
WINDOW_PROTOCOL='(if .shell == "xwayland" then "X11" else "wayland" end)'
|
|
|
|
WINDOW_GEOMETRY='(.rect | "\(.x),\(.y) \(.width)x\(.height) ")'
|
2022-04-08 15:47:38 +02:00
|
|
|
WINDOW_PID='(.id | tostring)'
|
2022-04-08 17:37:26 +02:00
|
|
|
CLEAR_OBJ="del(.focus, .pid, .border, .current_border_width, .window_rect, .orientation, .layout, .percent, .deco_rect, .geometry, .window, .urgent, .marks, .sticky, .fullscreen_mode, .nodes, .floating_nodes, .shell, .max_render_time, .visible, .idle_inhibitors, .inhibit_idle)"
|
2022-03-14 19:21:46 +01:00
|
|
|
|
|
|
|
# Output format, e.g. "1234 - 12:firefox (wayland)" or "5678 - 17:discord (X11)"
|
2022-04-08 15:47:38 +02:00
|
|
|
FILT="$ALL_NODES | $WINDOW_GEOMETRY + $WINDOW_PID"
|
2022-03-14 19:21:46 +01:00
|
|
|
|
|
|
|
function getprop() {
|
|
|
|
typeset -A views
|
|
|
|
local selected
|
|
|
|
|
|
|
|
while read POS GEOM INFO; do
|
|
|
|
views["$POS $GEOM"]="$INFO"
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
selected="$(printf "%s\n" "${!views[@]}" | slurp)"
|
|
|
|
if [[ -n "$selected" ]]; then
|
|
|
|
window_id=${views[${selected}]};
|
2022-04-08 15:47:38 +02:00
|
|
|
SELECT_ID=$(echo ".. | (.nodes? // empty)[] | select(.id == $window_id) | $CLEAR_OBJ ")
|
|
|
|
selected="$(swaymsg -t get_tree | jq -r "$ALL_NODES" | jq -c ". | select(.id==$window_id)" | jq)"
|
2022-05-12 19:42:09 +02:00
|
|
|
echo "$selected"
|
2022-04-08 15:47:38 +02:00
|
|
|
notify-send "Debug:" "$(echo $selected | jq -c "$CLEAR_OBJ" | jq)";
|
2022-03-14 19:21:46 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
swaymsg -t get_tree | jq -r "$FILT" | getprop
|