43 lines
1.3 KiB
Bash
Executable File
43 lines
1.3 KiB
Bash
Executable File
#!/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/screenshot-${timestamp}.png"
|
|
|
|
[ -d "$dir" ] || mkdir -p "$dir"
|
|
|
|
show_notification() {
|
|
dunstify --replace=699 -i "$1" "Screenshot" "$2"
|
|
}
|
|
|
|
countdown() {
|
|
for sec in $(seq "$1" -1 1); do
|
|
dunstify -t 1000 --replace=699 -i ~/.local/misc/share/assets/screenshot.svg "Taking shot in : $sec"
|
|
sleep 1
|
|
done
|
|
}
|
|
|
|
take_screenshot() {
|
|
maim -u "$filename"
|
|
xclip -selection clipboard -t image/png -i "$filename"
|
|
show_notification "$filename" "$1"
|
|
}
|
|
|
|
case $1 in
|
|
--now)
|
|
take_screenshot "Screensot saved and copied to clipboard";;
|
|
--in10)
|
|
countdown 10
|
|
take_screenshot "Scheduled capture taken after 10 seconds and copied to clipboard";;
|
|
--sel)
|
|
maim -u -s "$filename"
|
|
xclip -selection clipboard -t image/png -i "$filename"
|
|
show_notification "$filename" "Screenshot of selected area saved and copied to clipboard";;
|
|
--active)
|
|
maim -u -i "$(xdotool getactivewindow)" "$filename"
|
|
xclip -selection clipboard -t image/png -i "$filename"
|
|
show_notification "$filename" "Screenshot of active window saved and copied to clipboard";;
|
|
*)
|
|
take_screenshot "Screensot saved and copied to clipboard";;
|
|
esac |