aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Wilken2024-07-12 22:09:09 +0200
committerTimo Wilken2024-07-12 22:09:09 +0200
commit0b4e433403a23b439ff0a9bf3db50a5364095817 (patch)
tree6b8befe601a75a3e414414b72082fac7d2dade18
parentc52346c9b3a667cfee5e833ce295d2c7a519893a (diff)
Track wlprop script
-rw-r--r--tw/services/desktop.scm3
-rwxr-xr-xtw/services/files/wlprop14
2 files changed, 16 insertions, 1 deletions
diff --git a/tw/services/desktop.scm b/tw/services/desktop.scm
index 4e73bb56..3c302a06 100644
--- a/tw/services/desktop.scm
+++ b/tw/services/desktop.scm
@@ -587,7 +587,8 @@ corner_radius 6
,@common-xdg-configs)))
(define (home-wayland-files config)
- common-home-files)
+ `((".local/bin/wlprop" ,(local-file "files/wlprop" #:recursive? #t))
+ ,@common-home-files))
(define (home-wayland-environment config)
`(;; Smooth trackpad scrolling in Firefox/Icecat.
diff --git a/tw/services/files/wlprop b/tw/services/files/wlprop
new file mode 100755
index 00000000..f713b6f1
--- /dev/null
+++ b/tw/services/files/wlprop
@@ -0,0 +1,14 @@
+#!/bin/sh -e
+# https://gist.github.com/crispyricepc/f313386043395ff06570e02af2d9a8e0
+
+# Get the sway tree and store the output
+sway_tree=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?)')
+
+# Invoke slurp to let the user select a window, and extract
+# the x, y, width, and height from the selection.
+IFS=', x' read -r x y w h < <(echo "$sway_tree" | jq -r '.rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp -r)
+
+# Find the window matching the selection.
+echo "$sway_tree" |
+ jq --argjson x "$x" --argjson y "$y" --argjson w "$w" --argjson h "$h" \
+ '. | select(.rect.x == $x and .rect.y == $y and .rect.width == $w and .rect.height == $h)'