z_mirror/dotfiles
git clone https://git.raiguard.me/z_mirror/dotfiles
897abd7
noctalia
1#!/usr/bin/env sh 2# 3# Source: https://gist.github.com/crispyricepc/f313386043395ff06570e02af2d9a8e0 4# 5# wlprop 6# 7# Licensed under the MIT license 8# Copyright © 2022 bjosephmitchell@gmail.com 9# Permission is hereby granted, free of charge, to any person obtaining a copy 10# of this software and associated documentation files (the “Software”), to deal 11# in the Software without restriction, including without limitation the rights 12# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13# copies of the Software, and to permit persons to whom the Software is 14# furnished to do so, subject to the following conditions: 15# 16# The above copyright notice and this permission notice shall be included in all 17# copies or substantial portions of the Software. 18# 19# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25# SOFTWARE. 26# 27# Dependencies: 28# - swaymsg 29# - jq 30# - slurp 31# - awk 32 33# Get the sway tree and store the output 34SWAY_TREE=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?)') 35 36# Invoke slurp to let the user select a window 37SELECTION=$(echo $SWAY_TREE | jq -r '.rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp) 38 39# Extract the X, Y, Width, and Height from the selection 40X=$(echo $SELECTION | awk -F'[, x]' '{print $1}') 41Y=$(echo $SELECTION | awk -F'[, x]' '{print $2}') 42W=$(echo $SELECTION | awk -F'[, x]' '{print $3}') 43H=$(echo $SELECTION | awk -F'[, x]' '{print $4}') 44 45# Find the window matching the selection 46echo $SWAY_TREE | jq -r --argjson x $X --argjson y $Y --argjson w $W --argjson h $H \ 47 '. | select(.rect.x == $x and .rect.y == $y and .rect.width == $w and .rect.height == $h)'