#!/usr/bin/env bash # Originally created by - https://github.com/gh0stzk timestamp=$(date +%d_%m_%Y-%I-%M-%S) dir="$(xdg-user-dir PICTURES)/screenshots" filename="$dir/ss-${timestamp}.png" [ -d "$dir" ] || mkdir -p "$dir" show_notification() { if [[ -e "$filename" ]]; then dunstify --replace=699 -i "$filename" "Screenshot" "Screenshot saved and copied to clipboard" else dunstify --replace=699 -i custom-trash-bin "Screenshot" "Screenshot Canceled" fi } take_screenshot() { maim -u "$@" "$filename" xclip -selection clipboard -t image/png -i "$filename" show_notification } countdown() { for sec in $(seq "$1" -1 1); do dunstify -t 1000 --replace=699 -i ~/.local/misc/share/assets/screenshot.svg "Taking screenshot in : $sec" sleep 1 done } case $1 in --now) take_screenshot;; --in10) countdown 10 && take_screenshot;; --sel) take_screenshot -s -o;; --active) take_screenshot -i "$(xdotool getactivewindow)";; *) take_screenshot;; esac