This commit is contained in:
Joren 2025-01-09 14:18:58 +01:00
parent c310ce0049
commit f9bebb334e
Signed by: Joren
GPG Key ID: 280E33DFBC0F1B55

View File

@ -1,9 +1,7 @@
#!/bin/bash #!/bin/bash
SAVE_DIR="$HOME/Pictures/Screenshots" SAVE_DIR="$HOME/Pictures/Screenshots"
mkdir -p "$SAVE_DIR" mkdir -p "$SAVE_DIR"
FILENAME="$SAVE_DIR/screenshot_$(date +"%Y-%m-%d_%H-%M-%S").png" FILENAME="$SAVE_DIR/screenshot_$(date +"%Y-%m-%d_%H-%M-%S").png"
capture_full_screen() { capture_full_screen() {
@ -20,6 +18,12 @@ capture_window() {
grim -g "$window_geometry" "$FILENAME" grim -g "$window_geometry" "$FILENAME"
} }
open_editor() {
# Open the screenshot in GIMP, ImageMagick's display command, or any preferred editor
photoflare "$FILENAME" &
}
# Capture the screenshot based on the option passed
case "$1" in case "$1" in
--full) --full)
capture_full_screen capture_full_screen
@ -31,10 +35,16 @@ case "$1" in
capture_window capture_window
;; ;;
*) *)
echo "Invalid option. Usage: screengrab [--full|--select|--window]" echo "Invalid option. Usage: screengrab [--full|--select|--window] [--edit]"
exit 1 exit 1
;; ;;
esac esac
# Copy to clipboard and notify
wl-copy < "$FILENAME" && notify-send "Screengrab" "Screenshot copied to clipboard" wl-copy < "$FILENAME" && notify-send "Screengrab" "Screenshot copied to clipboard"
# If --edit flag is passed, open the screenshot in the editor
if [[ "$2" == "--edit" ]]; then
open_editor
fi