refactor: generating boxes for windows instead of selecting single pixel
This commit is contained in:
parent
0571ecf78c
commit
24ceb6c14f
1 changed files with 6 additions and 11 deletions
17
hyprshot
17
hyprshot
|
@ -66,17 +66,12 @@ function begin_grab() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function grab_window() {
|
function grab_window() {
|
||||||
# SELECTION is an array where the first element is the
|
local clients=`hyprctl -j clients | jq -r '[.[] | select(.workspace.id | contains('$(hyprctl -j monitors | jq -r 'map(.activeWorkspace.id) | join(",")')'))] | reverse'`
|
||||||
# selected x coordinate and the second element is the
|
# Generate boxes for each visible window and send that to slurp
|
||||||
# selected y coordinate.
|
# through stdin
|
||||||
local selection=(`slurp -pf "%x %y" 2>/dev/null`)
|
local boxes="$(echo $clients | jq -r '.[] | "\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"')"
|
||||||
|
Print "Boxes:\n%s\n" "$boxes"
|
||||||
[ -z $selection ] && exit 1;
|
slurp -r <<< "$boxes" 2>/dev/null
|
||||||
|
|
||||||
local x=${selection[0]}
|
|
||||||
local y=${selection[1]}
|
|
||||||
local client=`hyprctl -j clients | jq -r '[.[] | select(.workspace.id | contains('$(hyprctl -j monitors | jq -r 'map(.activeWorkspace.id) | join(",")')')) | select(.at[0] <= '$x' and '$x' <= .at[0] + .size[0] and .at[1] <= '$y' and '$y' <= .at[1] + .size[1])] | last'`
|
|
||||||
echo $client | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function args() {
|
function args() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue