Skip to content

hypr: added custom script to use wofi as xdph share-picker #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions bin/omarchy-xdph-share-picker
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions config/hypr/xdph.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
screencopy {
custom_picker_binary=omarchy-xdph-share-picker
}