diff options
Diffstat (limited to 'config/hypr/scripts/ScreenShot.sh')
| -rwxr-xr-x | config/hypr/scripts/ScreenShot.sh | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/config/hypr/scripts/ScreenShot.sh b/config/hypr/scripts/ScreenShot.sh index 29fe776a..1d5eeacf 100755 --- a/config/hypr/scripts/ScreenShot.sh +++ b/config/hypr/scripts/ScreenShot.sh @@ -1,27 +1,40 @@ #!/bin/bash -iDIR="$HOME/.config/dunst/icons" +iDIR="$HOME/.config/swaync/icons" +notify_cmd_shot="notify-send -h string:x-canonical-private-synchronous:shot-notify -u low -i ${iDIR}/picture.png" -time=$(date +%Y-%m-%d-%H-%M-%S) +time=$(date "+%d-%b_%H-%M-%S") dir="$(xdg-user-dir)/Pictures/Screenshots" file="Screenshot_${time}_${RANDOM}.png" +active_window_class=$(hyprctl -j activewindow | jq -r '(.class)') +active_window_file="Screenshot_${time}_${active_window_class}.png" +active_window_path="${dir}/${active_window_file}" + # notify and view screenshot -notify_cmd_shot="dunstify -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 + if [[ "$1" == "active" ]]; then + if [[ -e "${active_window_path}" ]]; then + ${notify_cmd_shot} "Screenshot of '${active_window_class}' Saved." + else + ${notify_cmd_shot} "Screenshot of '${active_window_class}' not Saved" + fi + else + local check_file="$dir/$file" + if [[ -e "$check_file" ]]; then + ${notify_cmd_shot} "Screenshot Saved." + else + ${notify_cmd_shot} "Screenshot NOT Saved." + fi + fi } + + # countdown countdown() { for sec in $(seq $1 -1 1); do - dunstify -h string:x-canonical-private-synchronous:shot-notify -t 1000 -i "$iDIR"/timer.png "Taking shot in : $sec" + notify-send -h string:x-canonical-private-synchronous:shot-notify -t 1000 -i "$iDIR"/timer.png "Taking shot in : $sec" sleep 1 done } @@ -59,6 +72,17 @@ shotarea() { notify_view } +shotactive() { + active_window_class=$(hyprctl -j activewindow | jq -r '(.class)') + active_window_file="Screenshot_${time}_${active_window_class}.png" + active_window_path="${dir}/${active_window_file}" + + hyprctl -j activewindow | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"' | grim -g - "${active_window_path}" + sleep 1 + notify_view "active" +} + + if [[ ! -d "$dir" ]]; then mkdir -p "$dir" fi @@ -73,8 +97,10 @@ elif [[ "$1" == "--win" ]]; then shotwin elif [[ "$1" == "--area" ]]; then shotarea +elif [[ "$1" == "--active" ]]; then + shotactive else - echo -e "Available Options : --now --in5 --in10 --win --area" + echo -e "Available Options : --now --in5 --in10 --win --area --active" fi exit 0 |
