feat(screenshots): add interactive screenshot capture utility

feat(screenshots): automate screenshot naming and storage

- Detect active Texmaker project directory automatically
- Fall back to manual directory selection when needed
- Prompt user for screenshot filename
- Prevent accidental filename collisions
- Copy screenshot name to clipboard automatically
- Capture screenshots using GNOME Screenshot area selection
- Allow repeated captures until user confirms the result
- Store screenshots directly in project documentation folders
- Add script documentation and usage instructions

ads
This commit is contained in:
Lucas Vivohost committed 2026-09-14 12:43:38 +02:00
1 parent 2c2bf379a8
commit e003cbb11f
1 file changed
+48
@@ -1,4 +1,52 @@
#!/bin/bash
###############################################################################
# Script Name: screenshot_grab.sh
#
# Description:
# Interactive screenshot capture tool for GNOME desktops.
#
# The script automatically determines a destination directory from an
# open Texmaker project when possible. If no Texmaker project is detected,
# the user is prompted to choose a destination folder manually.
#
# Features:
# - Automatic Texmaker project path detection
# - Manual directory selection fallback
# - User-defined screenshot filenames
# - Duplicate filename detection
# - Automatic filename copy to clipboard
# - Area screenshot capture using gnome-screenshot
# - Screenshot preview/confirmation loop
#
# Requirements:
# - Bash
# - zenity
# - gnome-screenshot
# - xclip
# - Texmaker (optional)
#
# Usage:
# ./screenshot_grab.sh
#
# Workflow:
# 1. Detect current Texmaker project folder or ask for a directory.
# 2. Enter a screenshot filename.
# 3. Filename is copied to the clipboard automatically.
# 4. Select a screen area using gnome-screenshot.
# 5. Confirm the result.
# 6. Retake the screenshot until satisfied.
#
# Output:
# <selected_directory>/<filename>.png
#
# Notes:
# - The line beginning with ### contains the default fallback directory.
# - Existing filenames are checked before capturing.
# - Cancelling any dialog exits the script.
#
###############################################################################
###/data/DatenLucas/Dokumente/Studium/Master/3.Semester/Mechatronische Systeme/Lernunterlagen/
DEFAULT_DIR="$(cat ~/scripts/screenshot_grab.sh | grep "###" | grep -v grep | sed 's/###//g')"
cont=1