[vimshot.sh]: Merge x11_vimshot.sh and wl_vimshot.sh

This commit is contained in:
2025-01-28 04:30:13 +00:00
parent 2f099e145b
commit 3e25e0fd8d
3 changed files with 12 additions and 21 deletions

14
src/wl_vimshot.sh → src/vimshot.sh Executable file → Normal file
View File

@ -3,7 +3,12 @@
# For use as part of my LaTeX note-taking workflow in Vim: create the figure environment, copy the file name, invoke this script, and select the region in the source material to be screenshotted.
basename=$(basename "$0")
filepath=$(wl-paste)
if [ $(pgrep -x "Xorg") ]; then
filepath=$(xclip -selection clipboard -out)
else
filepath=$(wl-paste)
fi
# check if the filepath is absolute or relative, and if relative, make absolute
if [ "${filepath#\/}" = "$filepath" ] || [ "${filepath#\~}" = "$filepath" ]; then
@ -13,6 +18,9 @@ fi
notify-send "$basename" "Taking screenshot to $filepath"
sleep 5
grim -g "$(slurp)" "$filepath"
notify-send --icon "$filepath" "$basename" "Screenshot saved to: $filepath"
if [ $(pgrep -x "Xorg") ]; then
maim --select --hidecursor "$filepath" && notify-send --icon "$filepath" "$basename" "Screenshot saved to: $filepath"
else
grim -g "$(slurp)" "$filepath" && notify-send --icon "$filepath" "$basename" "Screenshot saved to: $filepath"
fi

View File

@ -1,16 +0,0 @@
#!/bin/sh
# Script to take a wait a few seconds before taking a screenshot to the filepath in the clipboard.
# For use as part of my LaTeX note-taking workflow in Vim: create the figure environment, copy the file name, invoke this script, and select the region in the source material to be screenshotted.
basename=$(basename "$0")
filepath=$(xclip -selection clipboard -out)
# check if the filepath is absolute or relative, and if relative, make absolute
if [ "${filepath#\/}" = "$filepath" ] || [ "${filepath#\~}" = "$filepath" ]; then
filepath="$(pwd)/$filepath"
fi
notify-send "$basename" "Taking screenshot to $filepath"
sleep 5
maim --select --hidecursor "$filepath" && notify-send --icon "$filepath" "$basename" "Screenshot saved to: $filepath"