feat: use different .dtfiles config setup
This commit is contained in:
35
.config/sway/scripts/debug-window
Executable file
35
.config/sway/scripts/debug-window
Executable file
@ -0,0 +1,35 @@
|
||||
#!/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) ")'
|
||||
WINDOW_PID='(.id | tostring)'
|
||||
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)"
|
||||
|
||||
# Output format, e.g. "1234 - 12:firefox (wayland)" or "5678 - 17:discord (X11)"
|
||||
FILT="$ALL_NODES | $WINDOW_GEOMETRY + $WINDOW_PID"
|
||||
|
||||
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}]};
|
||||
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)"
|
||||
echo "$selected"
|
||||
echo "$selected" > /tmp/sway_debug_window.json
|
||||
notify-send "Debug:" "$(echo $selected | jq -c "$CLEAR_OBJ" | jq)";
|
||||
wezterm start -- nvim /tmp/sway_debug_window.json;
|
||||
fi
|
||||
}
|
||||
|
||||
swaymsg -t get_tree | jq -r "$FILT" | getprop
|
Reference in New Issue
Block a user