From 582c7ad0569e4bc52a86b38e9a51f07f41842e15 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Mon, 2 Sep 2024 17:36:35 +0800 Subject: init hyprland scripts --- hyprshot | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100755 hyprshot (limited to 'hyprshot') diff --git a/hyprshot b/hyprshot new file mode 100755 index 0000000..90dac61 --- /dev/null +++ b/hyprshot @@ -0,0 +1,85 @@ +#!/usr/bin/env bash + +# file +time=`date +%Y-%m-%d-%H-%M-%S` +dir="`xdg-user-dir PICTURES`/Screenshots" +file="Screenshot_${time}.png" + +# directory +if [[ ! -d "$dir" ]]; then + mkdir -p "$dir" +fi + +# notify and view screenshot +notify_view () { + notify_cmd_shot='dunstify -u low -h string:x-dunst-stack-tag:obscreenshot -i /usr/share/archcraft/icons/dunst/picture.png' + pngcheck ${dir}/"$file" > /dev/null + if [[ $? -eq 0 ]]; then + #${notify_cmd_shot} "Copied to clipboard." + if $($HOME/scripts/sysutil.sh getSound screenshot); then + $HOME/scripts/sysutil.sh playsound screen-capture.oga & + fi + viewnior ${dir}/"$file" + else + # the notifcation too annoying + #${notify_cmd_shot} "Screenshot Canceled." + rm "${dir}/$file" + exit 0 + fi + if [[ -e "$dir/$file" ]]; then + ${notify_cmd_shot} "Screenshot Saved." + else + ${notify_cmd_shot} "Screenshot Deleted." + fi +} + +# copy screenshot to clipboard +copy_shot () { + tee "$file" | wl-copy -t image/png +} + +# countdown +countdown () { + for sec in `seq $1 -1 1`; do + dunstify -t 1000 -h string:x-dunst-stack-tag:screenshottimer -i /usr/share/archcraft/icons/dunst/timer.png "Taking shot in : $sec" + sleep 1 + done +} + +# take shots +shotnow () { + cd ${dir} && grim - | copy_shot + notify_view +} + +shot5 () { + countdown '5' + sleep 1 && cd ${dir} && grim - | copy_shot + notify_view +} + +shot10 () { + countdown '10' + sleep 1 && cd ${dir} && grim - | copy_shot + notify_view +} + +shotarea () { + cd ${dir} && grim -g "$(slurp -d)" - | copy_shot + notify_view +} + +# execute +if [[ "$1" == "--now" ]]; then + shotnow +elif [[ "$1" == "--in5" ]]; then + shot5 +elif [[ "$1" == "--in10" ]]; then + shot10 +elif [[ "$1" == "--area" ]]; then + shotarea +else + echo -e "Available Options : --now --in5 --in10 --area" +fi + +exit 0 -- cgit v1.2.3