Skip to content

Commit 054b896

Browse files
authored
fix: support negative monitor offsets (#39)
1 parent c8056dd commit 054b896

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

hyprshot

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ function trim() {
7474
local max_width=`hyprctl monitors -j | jq -r '[.[] | if (.transform % 2 == 0) then (.x + .width) else (.x + .height) end] | max'`
7575
local max_height=`hyprctl monitors -j | jq -r '[.[] | if (.transform % 2 == 0) then (.y + .height) else (.y + .width) end] | max'`
7676

77+
local min_x=`hyprctl monitors -j | jq -r '[.[] | (.x)] | min'`
78+
local min_y=`hyprctl monitors -j | jq -r '[.[] | (.y)] | min'`
79+
7780
local cropped_x=$x
7881
local cropped_y=$y
7982
local cropped_width=$width
@@ -86,13 +89,13 @@ function trim() {
8689
cropped_height=$((max_height - y))
8790
fi
8891

89-
if ((x < 0)); then
90-
cropped_x=0
91-
cropped_width=$((cropped_width + x))
92+
if ((x < min_x)); then
93+
cropped_x="$min_x"
94+
cropped_width=$((cropped_width + x - min_x))
9295
fi
93-
if ((y < 0)); then
94-
cropped_y=0
95-
cropped_height=$((cropped_height + y))
96+
if ((y < min_y)); then
97+
cropped_y="$min_y"
98+
cropped_height=$((cropped_height + y - min_y))
9699
fi
97100

98101
local cropped=`printf "%s,%s %sx%s\n" \

0 commit comments

Comments
 (0)