From 81d293ee40225543ca5c6b152628225c50f4f6de Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 5 Oct 2026 15:17:16 +0200 Subject: Center the live preview on the active workspace magick display requests its own window position, and Hyprland honored it for the floating window: the preview opened off-screen on the second monitor. Extend the runtime rule with center and the workspace active at launch; re-registering the rule name replaces the previous one. Co-Authored-By: Claude Opus 5.5 --- fanfictioner | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fanfictioner b/fanfictioner index 063f349..440a870 100755 --- a/fanfictioner +++ b/fanfictioner @@ -389,11 +389,16 @@ def open_preview(f): so the tiling layout neither resizes it nor reflows.""" try: if os.environ.get("HYPRLAND_INSTANCE_SIGNATURE"): + # display asks X for its own position, which lands off-screen on another monitor: + # pin it centered on the active workspace. Re-registering the name replaces the rule. + ws = json.loads(subprocess.run(["hyprctl", "-j", "activeworkspace"], capture_output=True, + text=True).stdout or "{}").get("id", "") subprocess.run(["hyprctl", "eval", 'hl.window_rule({name = "fanfictioner-preview", ' - 'match = { title = "^fanfictioner preview$" }, float = true})'], capture_output=True) + 'match = { title = "^fanfictioner preview$" }, float = true, center = true' + + (f', workspace = "{ws}"' if ws else "") + "})"], capture_output=True) return subprocess.Popen(["magick", "display", "-update", "1", "-title", "fanfictioner preview", str(f)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - except OSError: + except (OSError, ValueError): return None -- cgit v1.2.3