aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/screenshot.sh
diff options
context:
space:
mode:
authorJustine Smithies <justine@smithies.me.uk>2025-06-15 12:39:53 +0100
committerJustine Smithies <justine@smithies.me.uk>2025-06-15 12:39:53 +0100
commitd80c9f3cc45bc90d0ae436e7b092c0d1bc442655 (patch)
tree56c4c2fc5c9c37b76a4f981fe110165dd1ca71bd /.local/bin/screenshot.sh
parentfdb28dcb2b9295aae378af1f9a38a1520b3d5ef4 (diff)
Updated for MaomaoWM to allow screenshotting the focused window
Diffstat (limited to '.local/bin/screenshot.sh')
-rwxr-xr-x.local/bin/screenshot.sh14
1 files changed, 7 insertions, 7 deletions
diff --git a/.local/bin/screenshot.sh b/.local/bin/screenshot.sh
index 4887d6e..9481323 100755
--- a/.local/bin/screenshot.sh
+++ b/.local/bin/screenshot.sh
@@ -1,5 +1,8 @@
#!/bin/sh
+# Get focused output
+output="$(mmsg -g | grep "selmon 1" | awk '{print$1}')"
+
case $1 in
selected-region)
# Take a screenshot of the selected region
@@ -11,21 +14,18 @@ case $1 in
;;
focused-window)
# Take a screenshot of the focused window
- pos=$(hyprctl -j activewindow | grep 'at' | tr -dc '0-9 ')
- xpos=$(echo "$pos" | awk '{ print $1 }')
+ xpos=$(mmsg -g -x -o "$output" | grep "x" | awk '{print$2}')
xpos=$((xpos-2))
- ypos=$(echo "$pos" | awk '{ print $2 }')
+ ypos=$(mmsg -g -x -o "$output" | grep "y" | awk '{print$2}')
ypos=$((ypos-2))
- size=$(hyprctl -j activewindow | grep 'size' | tr -dc '0-9 ')
- xsize=$(echo "$size" | awk '{ print $1 }')
- ysize=$(echo "$size" | awk '{ print $2 }')
+ xsize=$(mmsg -g -x -o "$output" | grep "width" | awk '{print$2}')
+ ysize=$(mmsg -g -x -o "$output" | grep "height" | awk '{print$2}')
xsize=$((xsize+4)) # Value added is 2 times the border width
ysize=$((ysize+4)) # Value added is 2 times the border width
grim -g "$xpos"",""$ypos $xsize""x""$ysize" -t jpeg ~/Pictures/Screenshots/"$(date +%Y-%m-%d_%H-%m-%s)".jpg
;;
*)
# Take a screenshot of the currently focused output and save it into screenshots
- output="$(hyprctl monitors | grep -B 12 'focused: yes' | grep 'Monitor' | awk '{ print $2 }')"
grim -o "$output" -t jpeg ~/Pictures/Screenshots/"$(date +%Y-%m-%d_%H-%m-%s)".jpg
;;
esac