Improve screenshotter

This commit is contained in:
edwark43 2023-12-22 04:53:08 +00:00
parent 1977068817
commit 0615d0c3ae
3 changed files with 46 additions and 47 deletions

View File

@ -53,19 +53,19 @@ super + alt + w
# Screenshot Now
Print
screenshoter --now
screenshotter --now
# Screenshot Select
ctrl + Print
screenshoter --sel
screenshotter --sel
# Screenshot in 10s
alt + Print
screenshoter --in10
screenshotter --in10
# Screenshot active window
shift + Print
screenshoter --active
screenshotter --active
# Manage brightness
XF86MonBrightness{Up,Down}

View File

@ -1,43 +0,0 @@
#!/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 screenshot 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 "Screenshot saved and copied to clipboard";;
--in10)
countdown 10
take_screenshot "Scheduled capture taken and copied to clipboard";;
--sel)
maim -u -s "$filename"
xclip -selection clipboard -t image/png -i "$filename"
show_notification "$filename" "Screenshot of the 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 the active window saved and copied to clipboard";;
*)
take_screenshot "Screenshot saved and copied to clipboard";;
esac

42
misc/bin/screenshotter Executable file
View File

@ -0,0 +1,42 @@
#!/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