aboutsummaryrefslogtreecommitdiff
path: root/home-manager/homeModules/attachments/hypr-scripts/hshot
diff options
context:
space:
mode:
authorspl3g <spleefer6@yandex.ru>2024-04-20 20:24:36 +0300
committerspl3g <spleefer6@yandex.ru>2025-05-01 14:58:53 +0300
commitf5970d988c68ae1d2ac56f0a35324cd442a26be7 (patch)
tree3c7fa7d524c7337c3b999fd577081a1230690072 /home-manager/homeModules/attachments/hypr-scripts/hshot
parentec0e9896dcc0c88ef49d2b2bf8126498d3c2acec (diff)
add modules
Diffstat (limited to 'home-manager/homeModules/attachments/hypr-scripts/hshot')
-rwxr-xr-xhome-manager/homeModules/attachments/hypr-scripts/hshot45
1 files changed, 45 insertions, 0 deletions
diff --git a/home-manager/homeModules/attachments/hypr-scripts/hshot b/home-manager/homeModules/attachments/hypr-scripts/hshot
new file mode 100755
index 0000000..0d02b9c
--- /dev/null
+++ b/home-manager/homeModules/attachments/hypr-scripts/hshot
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+declare -a cmd
+
+usage() {
+ echo -e "-m | monitor\n-s | slurp\n-w | active window\n-c | add copy"
+}
+
+monitor() {
+ cmd=("grim -o \"\$(hyprctl -j monitors | jq -r '.[] | select(.focused) | .name')\"")
+}
+
+slurp() {
+ cmd=("grim -g \"\$(slurp)\"")
+}
+
+window() {
+ cmd=("grim -g \"\$(hyprctl activewindow -j | jq -j '\"\(.at | .[0]),\(.at | .[1]) \(.size | .[0])x\(.size | .[1])\"')\"")
+}
+
+copy() {
+ if [[ -n ${cmd[0]} ]]; then
+ cmd+=("- | wl-copy")
+ else
+ usage
+ fi
+}
+
+while getopts ":mswc" opt; do
+ case ${opt} in
+ m) monitor;;
+ s) slurp;;
+ w) window;;
+ c) copy;;
+ *) usage
+ exit 1;;
+ esac
+done
+
+if [[ -z $1 ]]; then
+ usage
+ exit 1
+fi
+
+bash -c "${cmd[*]}"