From 654606df86c10b2d122be55c3db27f1d4e383150 Mon Sep 17 00:00:00 2001 From: The_miro Date: Sat, 4 Jul 2026 15:06:37 +0200 Subject: [PATCH] fix(hyprlua): spawn filepicker floating, compact, centred on the cursor The dialog was landing off-cursor and at ~half-screen. Two Hyprland gotchas were fighting each other: `move` is evaluated against the window's natural size and `size` is applied afterwards from the top-left, so a cursor_x-(window_w/2) move centred the pre-shrink window. zenity's file chooser also ignores --width/--height and has a ~738x363 GTK minimum. Fix the size at 760x460 and hard-code the move offsets to half that (380x230) so the shrunk window lands exactly on the pointer. Drop the dead zenity --width/--height sizing from the script. Co-Authored-By: Claude Opus 4.8 --- desktopenvs/hyprlua/hypr/usr/windowrules.lua | 13 ++++++++++--- desktopenvs/hyprlua/scripts/filepicker-clipboard.sh | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/desktopenvs/hyprlua/hypr/usr/windowrules.lua b/desktopenvs/hyprlua/hypr/usr/windowrules.lua index b12d726..a08a9d7 100644 --- a/desktopenvs/hyprlua/hypr/usr/windowrules.lua +++ b/desktopenvs/hyprlua/hypr/usr/windowrules.lua @@ -73,13 +73,20 @@ hl.window_rule({ size = "(monitor_w*0.2) (monitor_h*0.2)", }) --- filepicker — float near the top-left, sized 5% of the display +-- filepicker — float, fixed 760x460, centred on the cursor. +-- The size and move must be kept in sync by hand: Hyprland evaluates `move` +-- using the window's *natural* size and only then applies `size`, resizing +-- from the top-left. Using cursor_x-(window_w/2) would therefore centre the +-- natural (~1274x714) window and leave the shrunk one off-cursor, so the +-- offsets below are hard-coded to half the final size (380x230). zenity's +-- file chooser ignores --width/--height and has a ~738x363 GTK minimum, so +-- 760x460 is about as small as it goes while landing exactly on the pointer. hl.window_rule({ name = "filepicker", match = { tag = "filepicker" }, float = true, - move = "(monitor_w*0.05) (monitor_h*0.05)", - size = "(monitor_w*0.05) (monitor_h*0.05)", + size = "760 460", + move = "(cursor_x-380) (cursor_y-230)", }) -- spotify floating diff --git a/desktopenvs/hyprlua/scripts/filepicker-clipboard.sh b/desktopenvs/hyprlua/scripts/filepicker-clipboard.sh index 35af8f7..d702063 100755 --- a/desktopenvs/hyprlua/scripts/filepicker-clipboard.sh +++ b/desktopenvs/hyprlua/scripts/filepicker-clipboard.sh @@ -9,6 +9,7 @@ set -euo pipefail mode="${1:-path}" # zenity exits non-zero on cancel/close -> treat as a no-op. +# Float/size/cursor-centering are handled by the +filepicker window rule. file="$(zenity --file-selection --title="Copy file ${mode} to clipboard")" || exit 0 [ -n "$file" ] || exit 0