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 <noreply@anthropic.com>
feat/astal-menu
Amir Alexander Abdelbaki 2026-07-04 15:06:37 +02:00
parent 54338f3602
commit 654606df86
2 changed files with 11 additions and 3 deletions

View File

@ -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

View File

@ -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