commit 610cbe7d82b48a362c7e7c902421692abc908dde parent 090c4e30775782855751d2f4c8f10ab611340de9 Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Thu, 4 Jun 2020 14:14:00 +0200 Simplify screenshot script Diffstat:
M | .local/bin/maimpick | | | 19 | ++++++++++++------- |
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/.local/bin/maimpick b/.local/bin/maimpick @@ -1,9 +1,14 @@ #!/bin/sh -case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfullscreen (copy)" | dmenu -l 6 -i -p "Screenshot which area?")" in - "a selected area") maim --hidecursor -s ~/tmp/pic-selected-"$(date '+%y-%m-%d_%H:%M:%S').png" ;; - "current window") maim --hidecursor -i "$(xdotool getactivewindow)" ~/tmp/pic-window-"$(date '+%y-%m-%d_%H:%M:%S').png" ;; - "full screen") maim ~/tmp/pic-full-"$(date '+%y-%m-%d_%H:%M:%S').png" ;; - "a selected area (copy)") maim --hidecursor -s | xclip -selection clipboard -t image/png ;; - "current window (copy)") maim --hidecursor -i | xclip -selection clipboard -t image/png ;; - "full screen (copy)") maim | xclip -selection clipboard -t image/png ;; +set -e + +c="$(printf 'area\nwindow\nscreen' | dmenu -i)" +out="$(printf '%s/tmp/pic-%s-%s.png' "$HOME" "$c" "$(date '+%y-%m-%d_%H:%M:%S')" | dmenu -l 1 -p "outfile:")" + +case "$c" in + "area") + maim --hidecursor -s "$out" ;; + "window") + maim --hidecursor -i "$(xdotool getactivewindow)" "$out" ;; + "screen") + maim "$out" ;; esac