#!/bin/sh -e # a simple scrot wrapper to be used wm-agnostically usage() { echo "usage: $0 [-n|--no-notify] [mode]" echo echo " -n, --no-notify do not show a notification on success" 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 echo "note: last specified mode will be chosen" } scrot_cmd() { # scrot_cmd flags path _scrot_exec="echo \$f >/dev/null" [ "$_scrot_notify" = "YES" ] && { _scrot_exec="notify-send -t $_scrot_notify_duration \"scrot\" \ \"screenshot of $_scrot_human_readable_mode is saved to \$f\"" } # shellcheck disable=SC2086 scrot $1 "$2" -e "$_scrot_exec" } main() { _scrot_dir="$HOME/Pictures/Screenshots" _scrot_name="%Y-%m-%d-%s_\$wx\$h_scrot.png" _scrot_path="$_scrot_dir/$_scrot_name" _scrot_notify="YES" _scrot_notify_duration="3000" _scrot_flags="" _scrot_human_readable_mode="full screen" for arg in "$@" do case $arg in -n|--no-notify) _scrot_notify="NO" ;; -f|--full) _scrot_flags="" _scrot_human_readable_mode="full screen" ;; -a|--area) _scrot_flags="-sf" _scrot_human_readable_mode="screen area" ;; -c|--focused) _scrot_flags="-u" _scrot_human_readable_mode="active window" ;; *) usage exit 1 ;; esac done scrot_cmd "$_scrot_flags" "$_scrot_path" } main "$@"