From b9e80fbfbe435c0036efe73eb57744ea8d055408 Mon Sep 17 00:00:00 2001 From: The_miro Date: Sun, 5 Jul 2026 19:14:16 +0200 Subject: [PATCH] fix(astal-menu): stop LD_PRELOAD leaking into launched apps (Firefox crash) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit astal-menu-start.sh LD_PRELOADs libgtk4-layer-shell so it loads before libwayland-client. That preload is only needed at the daemon's own exec — the library is resident afterwards and the variable is never re-read — but every app started via AstalApps.launch() inherited it, and Firefox aborts at startup with libgtk4-layer-shell preloaded (gdk_display_manager_get() before gtk_init()). main.py now drops LD_PRELOAD from its environment right after startup, so launched GUI apps (and backend subprocesses) run with a clean env. Verified the layer-shell library stays mapped and the menu surface still maps afterwards. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01XUWCXM4KhjRkwheaA3X7bP --- desktopenvs/hyprlua/astal-menu/main.py | 9 +++++++++ desktopenvs/hyprlua/scripts/astal-menu-start.sh | 6 ++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/desktopenvs/hyprlua/astal-menu/main.py b/desktopenvs/hyprlua/astal-menu/main.py index 3ca517c..c561aed 100755 --- a/desktopenvs/hyprlua/astal-menu/main.py +++ b/desktopenvs/hyprlua/astal-menu/main.py @@ -13,9 +13,18 @@ toggles the running instance without spawning a new process. from __future__ import annotations +import os import sys from pathlib import Path +# astal-menu-start.sh LD_PRELOADs libgtk4-layer-shell so it loads before +# libwayland-client (a load-ordering requirement of the layer-shell library). That +# only matters at *this* process's exec: the library is already resident now, so the +# variable is never read again. Drop it here so the GUI apps we launch via +# AstalApps.launch() (and the backend subprocesses) don't inherit it — Firefox, for +# one, aborts at startup with libgtk4-layer-shell preloaded. +os.environ.pop("LD_PRELOAD", None) + # Make sibling modules importable no matter the CWD. sys.path.insert(0, str(Path(__file__).resolve().parent)) diff --git a/desktopenvs/hyprlua/scripts/astal-menu-start.sh b/desktopenvs/hyprlua/scripts/astal-menu-start.sh index 0add692..78fc4a8 100755 --- a/desktopenvs/hyprlua/scripts/astal-menu-start.sh +++ b/desktopenvs/hyprlua/scripts/astal-menu-start.sh @@ -3,8 +3,10 @@ # # gtk4-layer-shell must be loaded before libwayland-client; when the shell is used # through PyGObject that ordering isn't guaranteed, so we LD_PRELOAD it (the library -# itself documents this workaround). Starts the daemon hidden — it shows only when -# menu-toggle.sh forwards a --toggle/--show/--appdrawer verb. +# itself documents this workaround). main.py drops LD_PRELOAD from its environment +# right after startup so the apps it launches don't inherit it (Firefox, for one, +# crashes with libgtk4-layer-shell preloaded). Starts the daemon hidden — it shows +# only when menu-toggle.sh forwards a --toggle/--show/--appdrawer verb. APP="${HOME}/.config/astal-menu/main.py" SO="$(ldconfig -p 2>/dev/null | awk '/libgtk4-layer-shell\.so/ {print $NF; exit}')"