From 0615d0c3ae2793de5133552f6926638fa2519bfc Mon Sep 17 00:00:00 2001 From: edwark43 <97860398+edwark43@users.noreply.github.com> Date: Fri, 22 Dec 2023 04:53:08 +0000 Subject: [PATCH] Improve screenshotter --- config/sxhkd/sxhkdrc | 8 ++++---- misc/bin/screenshoter | 43 ------------------------------------------ misc/bin/screenshotter | 42 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 47 deletions(-) delete mode 100755 misc/bin/screenshoter create mode 100755 misc/bin/screenshotter diff --git a/config/sxhkd/sxhkdrc b/config/sxhkd/sxhkdrc index 70baf39..cc1f47c 100644 --- a/config/sxhkd/sxhkdrc +++ b/config/sxhkd/sxhkdrc @@ -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} diff --git a/misc/bin/screenshoter b/misc/bin/screenshoter deleted file mode 100755 index b5a3a4c..0000000 --- a/misc/bin/screenshoter +++ /dev/null @@ -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 \ No newline at end of file diff --git a/misc/bin/screenshotter b/misc/bin/screenshotter new file mode 100755 index 0000000..8ef2ebe --- /dev/null +++ b/misc/bin/screenshotter @@ -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 \ No newline at end of file