From c310ce0049ad0761f660089cddab52ab5e18b30f Mon Sep 17 00:00:00 2001 From: Joren Date: Mon, 23 Sep 2024 14:48:57 +0200 Subject: [PATCH] Add screenshot script --- ScreenShot/screengrab | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 ScreenShot/screengrab diff --git a/ScreenShot/screengrab b/ScreenShot/screengrab new file mode 100755 index 0000000..cedbeae --- /dev/null +++ b/ScreenShot/screengrab @@ -0,0 +1,40 @@ +#!/bin/bash + +SAVE_DIR="$HOME/Pictures/Screenshots" + +mkdir -p "$SAVE_DIR" + +FILENAME="$SAVE_DIR/screenshot_$(date +"%Y-%m-%d_%H-%M-%S").png" + +capture_full_screen() { + grim "$FILENAME" +} + +capture_selection() { + region=$(slurp) + grim -g "$region" "$FILENAME" +} + +capture_window() { + window_geometry=$(swaymsg -t get_tree | jq -r '.. | select(.focused?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"') + grim -g "$window_geometry" "$FILENAME" +} + +case "$1" in + --full) + capture_full_screen + ;; + --select) + capture_selection + ;; + --window) + capture_window + ;; + *) + echo "Invalid option. Usage: screengrab [--full|--select|--window]" + exit 1 + ;; +esac + +wl-copy < "$FILENAME" && notify-send "Screengrab" "Screenshot copied to clipboard" +