From bdde54602f5d8ddd5fc71f8b0dff3bb97e125d8f Mon Sep 17 00:00:00 2001 From: 0Karakurt0 Date: Sun, 24 Apr 2022 01:21:43 +0300 Subject: [PATCH] jq optimisation --- contrib/grimshot | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/contrib/grimshot b/contrib/grimshot index d42fe9d8..f475ad8f 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"