[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

View File

@ -34,8 +34,7 @@
- `stopwatch.sh`: simple stopwatch script that counts the elapsed time in seconds, and displays it in the format HH:MM:SS.
- `sync_music.sh`: script to sync my Android phone's music library to the contents of my `~/media/music/` directory, i.e. copy my music library from my
laptop to my phone.
- `vimshot.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.
- `webcam.sh`: one-line script that uses the video viewer program `mpv` as a webcam by using `/dev/video0` as its video file source.
- `wifi_dmenu.sh`: script to connect to an available WiFi network with a dmenu prompt.
- `wl_vimshot.sh`: Wayland 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.
of the screenshot via `notify-send`.
- `x11_vimshot.sh`: X11 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.

12
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")
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"