Dotfiles/desktopenvs/hyprlua/astal-menu
Amir Alexander Abdelbaki dc0436136b fix(astal-menu): fix layout-tab sync race across workspace switches
_sync_layout_controls() fires 3 concurrent hyprctl calls, and refresh()
can trigger it twice per open (once from the clients query, once from
the activeworkspace one) — each rebuilding a fresh set of layout
widgets. Two bugs followed:

1. The 3 callbacks each toggled the shared self._syncing flag
   independently (True at start, False at end). Whichever resolved
   first dropped the guard while the others — notably the tab-
   selection one, which programmatically flips the visible stack
   child — were still in flight. That let _on_tab_switch/_on_opt_change
   misfire as if the user had clicked, re-applying stale layout data
   via layouts.set() to whatever workspace was active by the time the
   callback landed.

2. A second _sync_layout_controls() call (from the redundant rebuild)
   could land mid-flight of the first, so a stale callback from sync
   #1 could decrement sync #2's guard or write sync #1's data into
   sync #2's freshly built widgets.

Fixed with a generation token: any sync superseded by a newer one is
invalidated outright, and self._syncing only lifts once the *current*
generation's 3 calls have all resolved. This is what "query the
current workspace's layout when opened, so it doesn't break switching
workspaces" needed — refresh() already re-queried on open, the gap was
in trusting stale in-flight results.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TLz6HWsXCwzQ97LrLt2em6
2026-07-09 16:48:42 +02:00
..
backend feat(astal-menu): pannable map with night/satellite tiles 2026-07-06 08:59:05 +02:00
lib feat(hyprlua): add astal-menu popup, replacing nwg-dock + nwg-drawer 2026-07-05 00:11:39 +02:00
modules feat(astal-menu): pannable map with night/satellite tiles 2026-07-06 08:59:05 +02:00
services feat(hyprlua): add astal-menu popup, replacing nwg-dock + nwg-drawer 2026-07-05 00:11:39 +02:00
style style(astal-menu): unfullscreen glyphs, animated takeover, CyberQueer TUIs 2026-07-07 13:43:11 +02:00
ui fix(astal-menu): fix layout-tab sync race across workspace switches 2026-07-09 16:48:42 +02:00
.gitignore feat(hyprlua): add astal-menu popup, replacing nwg-dock + nwg-drawer 2026-07-05 00:11:39 +02:00
README.md feat(hyprlua): add astal-menu popup, replacing nwg-dock + nwg-drawer 2026-07-05 00:11:39 +02:00
appservices.py feat(hyprlua): add astal-menu popup, replacing nwg-dock + nwg-drawer 2026-07-05 00:11:39 +02:00
main.py adjustments for astal+ewwbar 2026-07-08 21:56:51 +02:00
module_base.py feat(hyprlua): add astal-menu popup, replacing nwg-dock + nwg-drawer 2026-07-05 00:11:39 +02:00
paths.py fix(astal-menu): working favourites, 3-day weather, deploy-safe settings 2026-07-05 23:35:23 +02:00
registry.py feat(hyprlua): add astal-menu popup, replacing nwg-dock + nwg-drawer 2026-07-05 00:11:39 +02:00
settings.py fix(astal-menu): working favourites, 3-day weather, deploy-safe settings 2026-07-05 23:35:23 +02:00
theme.py fix(astal-menu): float modules on transparent gaps (beat theme's global bg) 2026-07-05 19:51:54 +02:00
window.py feat(astal-menu): Columns count stepper + expanded taskbar is one module 2026-07-07 13:31:45 +02:00

README.md

astal-menu

A touch-friendly GTK4 popup control centre for the hyprlua desktop, replacing nwg-dock and nwg-drawer. Triggered from the EWW top bar (or Super+D).

Layout: a 2×2 quad grid of feature modules over a full-width application drawer. Any quad can expand to overlay the other three; the drawer can expand to the bottom of the screen. A single margined root box letterboxes the menu identically in every state.

Stack

  • Frontend: Python + PyGObject + GTK4, as a wlr-layer-shell surface (gtk4-layer-shell). Chosen over Lua because lgi/Astal-Lua only support GTK3.
  • Location map: a static OSM image stitched from tiles (backend/staticmap.py, Pillow). libshumate does not paint tiles in this environment (the official shumate-demo shows the same blank map), though tile downloads work — hence the static fallback.
  • Services: Astal GObject libraries via introspection — AstalNetwork, AstalBluetooth, AstalApps — plus our own IP-geolocation singleton.
  • Backends: Python/Bash scripts in backend/ (JSON on stdout), run async via Gio.Subprocess so nothing blocks the UI.
  • Theme: style/_colors.css (@define-color, generated from ~/Dotfiles/colors.conf by apply-theme.sh) + style/style.css.

Running

main.py is single-instance. The autostart launches a hidden resident daemon; verbs are forwarded over D-Bus:

scripts/astal-menu-start.sh          # resident daemon (hidden); sets LD_PRELOAD
scripts/menu-toggle.sh               # --toggle
scripts/menu-toggle.sh appdrawer     # open with the app drawer expanded

astal-menu-start.sh must LD_PRELOAD libgtk4-layer-shell (it loads after libwayland under PyGObject otherwise).

Adding a module

  1. Create modules/<name>.py exposing a top-level SPEC = ModuleSpec(...) whose build(ctx) returns a ModuleInstance(compact=…, expanded=…, …).
    • compact shows in the 2×2 cell; a distinct expanded widget enables the expand button (they must be separate instances — GTK widgets have one parent).
    • Declare per-feature toggles via features=[Feature("id", "Label", default)]; read them with ctx.feature("id"). A disabled quad never calls build().
    • Shared state (network, bluetooth, location) is on ctx.services.
  2. Append its SPEC to ALL_SPECS in registry.py. Nothing else changes.

Files

main.py          app + single-instance IPC        window.py    layer-shell + letterbox
registry.py      module list (extension seam)      settings.py  JSON toggles/order
module_base.py   ModuleSpec / ModuleInstance / ModuleContext
appservices.py   shared Astal services + location
ui/              quadcard, quadgrid, appdrawer
modules/         location, weather, bluetooth, network
services/        location (geolocation singleton)
lib/             ansi (SGR→TextTag), proc (async subprocess)
backend/         geolocate.py, weather.sh, network.sh
style/           _colors.css, style.css