Bashrc.wiki: removed code from shot section. Just read the source

This commit is contained in:
David Thurstenson 2021-06-05 18:25:47 -05:00
parent e5ff970c37
commit 2ff12a87e5
1 changed files with 1 additions and 79 deletions

View File

@ -110,85 +110,7 @@ As an added bonus, the `-l` option will print the url for that product's support
https://git.thurstylark.com/vcsh/bashrc.git/tree/.bashrc.d/shot.bash
This function wraps `maim(1)` and `fb(1)` to simplify my most used options. It uses maim to capture either the full screen, the active window, or a mouse selection to a file, or directly to a pastebin.
{{{class="prettyprint"
shot() {
# Usage: shot XY
local destdir="$HOME/Pictures/screenshots"
local fname
local pb="fb"
local paste msgt msgd opts
fname="shot-$(date +%F-%T).png"
if [ -z "$1" ]; then
printf "
Usage: shot XY
X: Target
Y: Destination
Valid Targets:
w Active Window
a All displays
s Mouse Selection
Valid Destinations:
f Save to file (defined in function)
p Upload to a pastebin (defined in function)
"
return
fi
# X: What to capture
case ${1:0:1} in
# Active window
w) printf "Focus target window now...\n"
opts="-i $(xdotool getactivewindow)"
msgt="active window"
;;
# All
a) msgt="all displays"
;;
# Mouse selection
s) opts="-s --noopengl"
msgt="mouse selection"
;;
*) printf "Invalid target: %s\n" "${1:0:1}"
return
;;
esac
# Y: Where to put the result
case ${1:1:1} in
# Save to file
f) msgd="file: $destdir/$fname"
;;
# Post to a pastebin
p) destdir=$destdir/pasted
msgd="pastebin"
paste=1;;
*) printf "Invalid destination: %s\n" "${1:1:1}"
return
;;
esac
# Make sure destination directory will exist
[[ ! -d "$destdir" ]] && mkdir -p "$destdir"
local fpath="${destdir}/${fname}"
# If target is active window, give a 5 second countdown before running maim
[[ "$msgt" = "active window" ]] && countdown 5
maim "$opts" "$fpath"
printf "Captured %s -> %s\n" "$msgt" "$msgd"
# If destination is a pastebin, do the needful
[[ "$paste" ]] && $pb "$fpath"
}
}}}
This probably isn't the most robust solution, but it works pretty well. Patches welcome.
`shot()` used to be much more complicated, but after moving to sway, I found that I couldn't be arsed to reimplement all of its former functionality. It turned out that the majority of the time, I want to select a region, and put it on stdout to be dealt with how I please. If I find that full-screen or all-screen screenshots are more useful to me in the future, I'll cross that bridge when I come to it.
----