all repos — dotfiles @ f1a8419e0898ff0ce4db37a7e4ae92aff76d81fb

personal dotfiles

scrot_cmd: copy scrot to clipboard by default

and add flag to disable this option
la-ninpre leobrekalini@gmail.com
Sun, 10 Apr 2022 17:59:51 +0300
commit

f1a8419e0898ff0ce4db37a7e4ae92aff76d81fb

parent

6bc3644cc96445ad387f6a55dabdbbd5d232eea6

1 files changed, 14 insertions(+), 4 deletions(-)

jump to
M bin/.local/bin/scrot_cmdbin/.local/bin/scrot_cmd

@@ -3,14 +3,16 @@

# a simple scrot wrapper to be used wm-agnostically usage() { - echo "usage: $0 [-n|--no-notify] [mode]" + echo "usage: $0 [options] [mode]" echo + echo "options:" echo " -n, --no-notify do not show a notification on success" + echo " -x, --no-copy don't copy capture to clipboard" echo echo "modes:" echo " -f, --full capture the whole screen" echo " -a, --area select area and capture it" - echo " -c, --focused capture only focused window" + echo " -w, --focused capture only focused window" echo echo "note: last specified mode will be chosen" }

@@ -18,12 +20,16 @@

scrot_cmd() { # scrot_cmd flags path - _scrot_exec="echo \$f >/dev/null" + _scrot_exec="true" [ "$_scrot_notify" = "YES" ] && { _scrot_exec="notify-send -t $_scrot_notify_duration \"scrot\" \ \"screenshot of $_scrot_human_readable_mode is saved to \$f\"" } + [ "$_scrot_copy_to_clipboard" = "YES" ] && { + _scrot_exec="$_scrot_exec && cat \$f | xclip -t image/png -sel c" + } + # shellcheck disable=SC2086 scrot $1 "$2" -e "$_scrot_exec" }

@@ -35,6 +41,7 @@ _scrot_name="%Y-%m-%d-%s_\$wx\$h_scrot.png"

_scrot_path="$_scrot_dir/$_scrot_name" _scrot_notify="YES" _scrot_notify_duration="3000" + _scrot_copy_to_clipboard="YES" _scrot_flags="" _scrot_human_readable_mode="full screen"

@@ -52,9 +59,12 @@ -a|--area)

_scrot_flags="-s -f" _scrot_human_readable_mode="screen area" ;; - -c|--focused) + -w|--focused) _scrot_flags="-u" _scrot_human_readable_mode="active window" + ;; + -x|--no-copy) + _scrot_copy_to_clipboard="NO" ;; *) usage