From c001a1c26eb6e2f2aaeebf8c529c26963a4d219e Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 24 Oct 2024 01:25:14 +0100 Subject: [PATCH] [vimshot.sh]: Add vimshot.sh --- README.md | 1 + vimshot.sh | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100755 vimshot.sh diff --git a/README.md b/README.md index dddee4e..914bfd5 100644 --- a/README.md +++ b/README.md @@ -33,5 +33,6 @@ - `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. diff --git a/vimshot.sh b/vimshot.sh new file mode 100755 index 0000000..2fb15b3 --- /dev/null +++ b/vimshot.sh @@ -0,0 +1,18 @@ +#!/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"