From c10d8aaaccf728482237d97262dd1cc3a1fbb5f6 Mon Sep 17 00:00:00 2001 From: David Thurstenson Date: Mon, 30 Nov 2020 13:14:23 -0600 Subject: [PATCH] Massively simplifying shot to most-used options, and after moving to sway as primary DE --- .bashrc.d/shot.bash | 77 ++------------------------------------------- 1 file changed, 2 insertions(+), 75 deletions(-) diff --git a/.bashrc.d/shot.bash b/.bashrc.d/shot.bash index cb45c06..201dc40 100644 --- a/.bashrc.d/shot.bash +++ b/.bashrc.d/shot.bash @@ -1,77 +1,4 @@ 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" - 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 - if [[ "$msgt" = "active window" ]]; then - countdown 5 - opts="-i $(xdotool getactivewindow)" - fi - - maim $opts "$fpath" - printf "Captured %s -> %s\n" "$msgt" "$msgd" - - # If destination is a pastebin, do the needful - [[ "$paste" ]] && $pb "$fpath" + # Select a region, output to stdout + slurp | grim -g - - }