aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/screenshot.sh
diff options
context:
space:
mode:
authorJustine Smithies <justine@smithies.me.uk>2026-01-24 17:24:58 +0000
committerJustine Smithies <justine@smithies.me.uk>2026-01-24 17:24:58 +0000
commit1d6a548bcbe85ee95e986c475b23733c2977bf04 (patch)
tree7605c43bf5b4f4044a606c6b404ab9d71cd55ddc /.local/bin/screenshot.sh
parent818cb6579e422a03da5564ef93715f43f969954c (diff)
Initial commit
Diffstat (limited to '.local/bin/screenshot.sh')
-rwxr-xr-x.local/bin/screenshot.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/.local/bin/screenshot.sh b/.local/bin/screenshot.sh
new file mode 100755
index 0000000..9481323
--- /dev/null
+++ b/.local/bin/screenshot.sh
@@ -0,0 +1,31 @@
+#!/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
+ grim -t jpeg -g "$(slurp)" ~/Pictures/Screenshots/"$(date +%Y-%m-%d_%H-%m-%s)".jpg
+ ;;
+ save-to-clipboard)
+ # Take a screenshot and save it to the clipboard
+ grim -g "$(slurp -d)" - | wl-copy
+ ;;
+ focused-window)
+ # Take a screenshot of the focused window
+ xpos=$(mmsg -g -x -o "$output" | grep "x" | awk '{print$2}')
+ xpos=$((xpos-2))
+ ypos=$(mmsg -g -x -o "$output" | grep "y" | awk '{print$2}')
+ ypos=$((ypos-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
+ grim -o "$output" -t jpeg ~/Pictures/Screenshots/"$(date +%Y-%m-%d_%H-%m-%s)".jpg
+ ;;
+esac