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:
1 parent
2c2bf379a8
commit
e003cbb11f
1 file changed
+48
Executable
+99
@@ -0,0 +1,99 @@
|
||||
#!/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
|
||||
PATH="$(ps -elf | grep -v grep | grep -o -P '(?<=texmaker ).*(?=/.*\.tex)')/"
|
||||
if [ "$PATH" == "/" ]; then
|
||||
# /usr/bin/zenity --error --text="No Filepath detected"
|
||||
# exit 0
|
||||
while [ $cont -eq 1 ]; do
|
||||
PATH="$(/usr/bin/zenity --file-selection --title="No TEX open: Where the FUCK shall I go???" --directory --width=600 --height=400 --filename="$DEFAULT_DIR")"
|
||||
ret=$?
|
||||
if [[ "$PATH" != "/" ]] && [[ -d "$PATH" ]] && [[ $ret -eq 0 ]]; then
|
||||
cont=0
|
||||
elif [[ $ret -eq 1 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
PATH="$PATH/"
|
||||
fi
|
||||
text="Filename exists:"
|
||||
NAME="$(/usr/bin/zenity --entry --ok-label="Fuck" --title="Filename" --text="Enter Name:")"
|
||||
while [ $cont -eq 1 ]; do
|
||||
if [ -a "$PATH$NAME.png" ]; then
|
||||
NEWNAME="$(/usr/bin/zenity --entry --entry-text="$NAME" --cancel-label="Fuck It!" --ok-label="New Fuck" --title="Shit Shit Shit" --text="$text")"
|
||||
ret=$?
|
||||
if [[ "$NEWNAME" == "" ]] && [[ $ret -eq 1 ]]; then
|
||||
cont=0
|
||||
elif [[ "$NAME" != "$NEWNAME" ]] && [[ $ret -eq 0 ]]; then
|
||||
NAME=$NEWNAME
|
||||
cont=0
|
||||
elif [[ "$NAME" == "$NEWNAME" ]] && [[ $ret -eq 0 ]]; then
|
||||
text="I said new name you stupd fucking Idiot"
|
||||
else
|
||||
/usr/bin/zenity --error --title "Fuck Fuck Fuck Error" --text='Some Fucking unexpected State'
|
||||
fi
|
||||
else
|
||||
cont=0
|
||||
fi
|
||||
done
|
||||
if [ "$NAME" == "" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
printf "%s" "$NAME" | /usr/bin/xclip -sel clip
|
||||
NAME="$NAME.png"
|
||||
printf "%s\n" "$PATH$NAME"
|
||||
cont=1
|
||||
while [ $cont -eq 1 ]; do
|
||||
/usr/bin/gnome-screenshot -a -f "$PATH$NAME"
|
||||
/usr/bin/zenity --title="Confirmation" --text="Picture OK?" --ok-label="Fuck Yes" --cancel-label="Fuck No" --question
|
||||
cont=$?
|
||||
done
|
||||
Reference in new issue
Block a user