From bdde54602f5d8ddd5fc71f8b0dff3bb97e125d8f Mon Sep 17 00:00:00 2001 From: 0Karakurt0 Date: Sun, 24 Apr 2022 01:21:43 +0300 Subject: [PATCH 1/2] jq optimisation --- contrib/grimshot | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/contrib/grimshot b/contrib/grimshot index d42fe9d84..f475ad8fd 100755 --- a/contrib/grimshot +++ b/contrib/grimshot @@ -131,10 +131,9 @@ elif [ "$SUBJECT" = "area" ] ; then fi WHAT="Area" elif [ "$SUBJECT" = "active" ] ; then - FOCUSED=$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?, .floating_nodes[]?) | select(.focused)') - GEOM=$(echo "$FOCUSED" | jq -r '.rect | "\(.x),\(.y) \(.width)x\(.height)"') - APP_ID=$(echo "$FOCUSED" | jq -r '.app_id') - WHAT="$APP_ID window" + eval "$( swaymsg -t get_tree |\ + jq -r '..|try select(.focused == true)| + "GEOM=\"\(.rect.x),\(.rect.y) \(.rect.width)x\(.rect.height)\"\nAPP_ID=\"\(.app_id)\"\nWHAT=\"\(.app_id) window\""' )" elif [ "$SUBJECT" = "screen" ] ; then GEOM="" WHAT="Screen" From 5fce06c20bf902a2b222c4858bf1bbbe21dee7d4 Mon Sep 17 00:00:00 2001 From: Karakurt <43828023+0Karakurt0@users.noreply.github.com> Date: Mon, 2 May 2022 23:19:03 +0300 Subject: [PATCH 2/2] Improved readability --- contrib/grimshot | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contrib/grimshot b/contrib/grimshot index f475ad8fd..6d1468b35 100755 --- a/contrib/grimshot +++ b/contrib/grimshot @@ -133,7 +133,9 @@ elif [ "$SUBJECT" = "area" ] ; then elif [ "$SUBJECT" = "active" ] ; then eval "$( swaymsg -t get_tree |\ jq -r '..|try select(.focused == true)| - "GEOM=\"\(.rect.x),\(.rect.y) \(.rect.width)x\(.rect.height)\"\nAPP_ID=\"\(.app_id)\"\nWHAT=\"\(.app_id) window\""' )" + "GEOM=\"\(.rect.x),\(.rect.y) \(.rect.width)x\(.rect.height)\" + APP_ID=\"\(.app_id)\" + WHAT=\"\(.app_id) window\""' )" elif [ "$SUBJECT" = "screen" ] ; then GEOM="" WHAT="Screen"