aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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