From 691bef0a5e3589b7db936a29341a3eaeb2a6b319 Mon Sep 17 00:00:00 2001 From: Andrej Benz Date: Sat, 12 Jul 2025 13:04:08 +0200 Subject: [PATCH] hypr: added custom script to use wofi as xdph share-picker --- bin/omarchy-xdph-share-picker | 56 +++++++++++++++++++++++++++++++++++ config/hypr/xdph.conf | 3 ++ 2 files changed, 59 insertions(+) create mode 100755 bin/omarchy-xdph-share-picker create mode 100644 config/hypr/xdph.conf diff --git a/bin/omarchy-xdph-share-picker b/bin/omarchy-xdph-share-picker new file mode 100755 index 000000000000..a8df282c299c --- /dev/null +++ b/bin/omarchy-xdph-share-picker @@ -0,0 +1,56 @@ +#!/bin/bash + +monitors=$(wlr-randr --json | jq '.[] | .name') +windows="${XDPH_WINDOW_SHARING_LIST}" + +result="" + +# Add monitors to result +while IFS= read -r monitor; do + monitor=$(echo "$monitor" | tr -d '"') # Remove quotes from monitor name + if [ -n "$result" ]; then + result="${result}\n" + fi + result="${result}${monitor}\tscreen: ${monitor}" +done <<< "$monitors" + +# Add region entry +if [ -n "$result" ]; then + result="${result}\n" +fi +result="${result}region\tSelection Region" + +# Add windows to result +while IFS= read -r line; do + if [ -n "$result" ]; then + result="${result}\n" + fi + result="${result}${line}" +done < <(echo "$windows" | awk -F'\\[HE>\\]' '{ + for(i=1; i<=NF; i++) { + if ($i == "") continue; + + split($i, window, "\\[HC>\\]"); + id = window[1]; + + split(window[2], parts, "\\[HT>\\]"); + class = parts[1]; + title = parts[2]; + + if (id != "") + print id "\t" "window: " title; + } +}') + +selection=$(echo -e "$result" | wofi -d) + +if [[ $selection == *"screen"* ]]; then + monitor=$(echo "$selection" | cut -f1) + echo "[SELECTION]/screen:${monitor}" +elif [[ $selection == *"window"* ]]; then + window_id=$(echo "$selection" | cut -f1) + echo "[SELECTION]/window:${window_id}" +elif [[ $selection == *"region"* ]]; then + region=$(slurp -f "%o@%x,%y,%w,%h") + echo "[SELECTION]/region:${region}" +fi diff --git a/config/hypr/xdph.conf b/config/hypr/xdph.conf new file mode 100644 index 000000000000..8ffdc98a6f6e --- /dev/null +++ b/config/hypr/xdph.conf @@ -0,0 +1,3 @@ +screencopy { + custom_picker_binary=omarchy-xdph-share-picker +}