aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/scripts/ScreenShot.sh
diff options
context:
space:
mode:
authorJaKooLit <jimmielovejay@gmail.com>2023-12-27 00:37:26 +0900
committerJaKooLit <jimmielovejay@gmail.com>2023-12-27 00:37:26 +0900
commit0bdc93e101308e6aa43438dcb0de67182a865622 (patch)
tree3f575f19ed474a10451f30d2f6ba6e031a1cafaf /config/hypr/scripts/ScreenShot.sh
parent453d8b3f439d022569ea0b077e7c69039d96746a (diff)
updated swaync
Diffstat (limited to 'config/hypr/scripts/ScreenShot.sh')
-rwxr-xr-xconfig/hypr/scripts/ScreenShot.sh48
1 files changed, 37 insertions, 11 deletions
diff --git a/config/hypr/scripts/ScreenShot.sh b/config/hypr/scripts/ScreenShot.sh
index 06826275..44ba2bd6 100755
--- a/config/hypr/scripts/ScreenShot.sh
+++ b/config/hypr/scripts/ScreenShot.sh
@@ -1,27 +1,40 @@
#!/bin/bash
iDIR="$HOME/.config/dunst/icons"
+notify_cmd_shot="dunstify -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="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
+ if [[ "$1" == "active" ]]; then
+ if [[ -e "${active_window_path}" ]]; then
+ ${notify_cmd_shot} "Screenshot of '${active_window_class}' is saved."
+ else
+ ${notify_cmd_shot} "Screenshot of '${active_window_class}' is deleted or not available."
+ fi
+ else
+ local check_file="$dir/$file"
+ if [[ -e "$check_file" ]]; then
+ ${notify_cmd_shot} "Screenshot Saved."
+ else
+ ${notify_cmd_shot} "Screenshot Deleted."
+ fi
+ 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"
+ dunstify -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
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage