diff options
| author | JaKooLit <jimmielovejay@gmail.com> | 2023-10-22 15:55:57 +0900 |
|---|---|---|
| committer | JaKooLit <jimmielovejay@gmail.com> | 2023-10-22 15:55:57 +0900 |
| commit | c222e1bad2ba5e779c3af5b956906c82ead43271 (patch) | |
| tree | a5253e0861c200ff90354169e1f67ef42ebf0ef9 /config/hypr/scripts/ScreenShot.sh | |
| parent | bb0be21dba7980fc1c047eaba24eda1712bd7f31 (diff) | |
Initial upload
Diffstat (limited to 'config/hypr/scripts/ScreenShot.sh')
| -rwxr-xr-x | config/hypr/scripts/ScreenShot.sh | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/config/hypr/scripts/ScreenShot.sh b/config/hypr/scripts/ScreenShot.sh new file mode 100755 index 00000000..06826275 --- /dev/null +++ b/config/hypr/scripts/ScreenShot.sh @@ -0,0 +1,80 @@ +#!/bin/bash + +iDIR="$HOME/.config/dunst/icons" + +time=$(date +%Y-%m-%d-%H-%M-%S) +dir="$(xdg-user-dir)/Pictures/Screenshots" +file="Screenshot_${time}_${RANDOM}.png" + +# notify and view screenshot +notify_cmd_shot="notify-send -h string:x-canonical-private-synchronous:shot-notify -u low -i ${iDIR}/picture.png" +notify_view() { + ${notify_cmd_shot} "Copied to clipboard." +## viewnior ${dir}/"$file" + if [[ -e "$dir/$file" ]]; then + ${notify_cmd_shot} "Screenshot Saved." + else + ${notify_cmd_shot} "Screenshot Deleted." + fi +} + +# countdown +countdown() { + for sec in $(seq $1 -1 1); do + notify-send -h string:x-canonical-private-synchronous:shot-notify -t 1000 -i "$iDIR"/timer.png "Taking shot in : $sec" + sleep 1 + done +} + +# take shots +shotnow() { + cd ${dir} && grim - | tee "$file" | wl-copy + sleep 2 + notify_view +} + +shot5() { + countdown '5' + sleep 1 && cd ${dir} && grim - | tee "$file" | wl-copy + sleep 1 + notify_view + +} + +shot10() { + countdown '10' + sleep 1 && cd ${dir} && grim - | tee "$file" | wl-copy + notify_view +} + +shotwin() { + w_pos=$(hyprctl activewindow | grep 'at:' | cut -d':' -f2 | tr -d ' ' | tail -n1) + w_size=$(hyprctl activewindow | grep 'size:' | cut -d':' -f2 | tr -d ' ' | tail -n1 | sed s/,/x/g) + cd ${dir} && grim -g "$w_pos $w_size" - | tee "$file" | wl-copy + notify_view +} + +shotarea() { + cd ${dir} && grim -g "$(slurp)" - | tee "$file" | wl-copy + notify_view +} + +if [[ ! -d "$dir" ]]; then + mkdir -p "$dir" +fi + +if [[ "$1" == "--now" ]]; then + shotnow +elif [[ "$1" == "--in5" ]]; then + shot5 +elif [[ "$1" == "--in10" ]]; then + shot10 +elif [[ "$1" == "--win" ]]; then + shotwin +elif [[ "$1" == "--area" ]]; then + shotarea +else + echo -e "Available Options : --now --in5 --in10 --win --area" +fi + +exit 0 |
