aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-05 15:17:16 +0200
committerDanilo M. <danix@danix.xyz>2026-10-05 15:17:16 +0200
commit81d293ee40225543ca5c6b152628225c50f4f6de (patch)
treee5af205c2422228535b4eec5c874cba8fa2f284c
parent45ab8ec26c95f580bfcacf401ffb5ea8717e3c2e (diff)
downloadfanfictioner-81d293ee40225543ca5c6b152628225c50f4f6de.tar.gz
fanfictioner-81d293ee40225543ca5c6b152628225c50f4f6de.zip
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 <noreply@anthropic.com>
-rwxr-xr-xfanfictioner9
1 files 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