aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/screenshot.sh
diff options
context:
space:
mode:
authorJustine Smithies <justine@smithies.me.uk>2024-11-08 20:43:20 +0000
committerJustine Smithies <justine@smithies.me.uk>2024-11-08 20:43:20 +0000
commit8d0bdf6bef075ea538f05759528e58bad166b924 (patch)
treefe823b1ef3ca8f041d37c480b0c99ae4393a48f8 /.local/bin/screenshot.sh
parent47f3bc8e0a8784f849cce23c9dfa72d1ea1d22b0 (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..cc9d3a6
--- /dev/null
+++ b/.local/bin/screenshot.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+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
+ pos=$(hyprctl -j activewindow | grep 'at' | tr -dc '0-9 ')
+ xpos=$(echo "$pos" | awk '{ print $1 }')
+ xpos=$((xpos-2))
+ ypos=$(echo "$pos" | 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=$((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