From e532e9e086092e56bfb90d29c5adefec801a2025 Mon Sep 17 00:00:00 2001 From: Joren Date: Sun, 23 Jun 2024 02:25:20 +0200 Subject: [PATCH] Upload files to "/" --- screengrab | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 screengrab diff --git a/screengrab b/screengrab new file mode 100644 index 0000000..0383993 --- /dev/null +++ b/screengrab @@ -0,0 +1,42 @@ +#!/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() { + # Use slurp to select region + 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" + +