summaryrefslogtreecommitdiff
path: root/hyprshot
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2024-09-02 17:36:35 +0800
committerlittleblack111 <littleblack11111@gmail.com>2024-09-02 17:36:35 +0800
commit582c7ad0569e4bc52a86b38e9a51f07f41842e15 (patch)
tree49bd07d6e6cfc85ee9d825ead224fbaed98160b4 /hyprshot
parent4bafe49e51237da9f4f92c935912426d3661cc11 (diff)
init hyprland scripts
Diffstat (limited to 'hyprshot')
-rwxr-xr-xhyprshot85
1 files changed, 85 insertions, 0 deletions
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