Skip to content

fix(asusd-user): wait dynamically for system daemon on D-Bus#185

Merged
Ghoul4500 merged 4 commits into
OpenGamingCollective:mainfrom
scardracs:bugfix/issue-183-hotkeys-startup
Jul 23, 2026
Merged

fix(asusd-user): wait dynamically for system daemon on D-Bus#185
Ghoul4500 merged 4 commits into
OpenGamingCollective:mainfrom
scardracs:bugfix/issue-183-hotkeys-startup

Conversation

@scardracs

@scardracs scardracs commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Problem & Symptoms

On several ASUS ROG laptop models (e.g., Strix SCAR 16 G635LW) using version 6.3.9, special hotkeys (Volume Up/Down, Mic Mute, Fan profile speed toggle, ROG Key) ceased working after system boot.

Root Cause

In version 6.3.9, the system daemon (asusd) performs several complex/asynchronous initialization tasks on startup (such as default fan curve ACPI queries, XG Mobile LED checks, and D-Bus firmware attribute registration), which noticeably prolonged its overall boot sequence. The user-level daemon (asusd-user) was configured to start blindly after a 2-second sleep (ExecStartPre=/usr/bin/sleep 2 in the systemd user service). Because asusd took longer than 2 seconds to register its name (xyz.ljones.Asusd) on D-Bus:

  1. asusd-user failed to query the available D-Bus interfaces and crashed on start.
  2. Under systemd's default restart policies (StartLimitBurst=2 in 200 seconds), asusd-user exhausted its startup attempts after two failures and was permanently disabled for the rest of the boot session, breaking all special hotkeys.
    Furthermore, keeping StartLimitBurst=2 meant that if the system daemon was restarted manually a couple of times during a session, the user daemon would crash (due to D-Bus disconnection) and quickly hit the restart limits, leaving the service disabled permanently until manually restarted.

Proposed Changes

This PR resolves the startup race condition and improves the overall robustness of the user service:

  1. Dynamic D-Bus Wait in asusd-user (Commit 1):

    • Replaced the immediate startup crash in list_iface_blocking() at boot with a deterministic check of the D-Bus name owner status.
    • If xyz.ljones.Asusd has no owner yet, the daemon subscribes to the D-Bus system daemon's NameOwnerChanged signal and blocks dynamically.
    • Once asusd registers its name and becomes ready, asusd-user breaks the loop and continues its initialization. This is fully event-driven and resource-friendly.
  2. Systemd Service Clean Up & Restart Limits Removal (Commit 2):

    • Removed the obsolete ExecStartPre=/usr/bin/sleep 2 from data/asusd-user.service, enabling the service to spawn instantly and wait cleanly in code.
    • Removed the aggressive StartLimitInterval=200 and StartLimitBurst=2 options, delegating rate-limiting of restarts to standard systemd defaults (e.g., 5 restarts in 10 seconds), preventing the daemon from getting stuck in an inactive state.

Commits

  • fix(asusd-user): wait dynamically for system daemon on D-Bus — Updates asusd-user/src/daemon.rs with the dynamic wait logic.
  • fix(systemd): clean up user service startup and restart limits — Updates data/asusd-user.service to remove the sleep workaround and the start limit constraints.

@scardracs
scardracs force-pushed the bugfix/issue-183-hotkeys-startup branch from de02cd0 to d277f67 Compare July 21, 2026 08:20

@Ghoul4500 Ghoul4500 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason why we can't simply do something like

[Unit]
After=asusd.service
Wants=asusd.service

if we are doing any waiting though, adding timeout is also important

Comment thread asusd-user/src/daemon.rs Outdated
@scardracs

Copy link
Copy Markdown
Contributor Author

Is there any reason why we can't simply do something like

[Unit]
After=asusd.service
Wants=asusd.service

if we are doing any waiting though, adding timeout is also important

A user-level systemd instance cannot see or wait for system-level services directly in After=. A user service can only see other user services.

@scardracs
scardracs force-pushed the bugfix/issue-183-hotkeys-startup branch from d277f67 to 5fc5231 Compare July 21, 2026 15:31
Comment thread asusd-user/src/daemon.rs Outdated
Comment thread asusd-user/src/daemon.rs Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a startup race between asusd-user and the system daemon (asusd) by replacing a fixed systemd sleep with an event-driven wait for xyz.ljones.Asusd to appear on the system bus, improving hotkey reliability after boot and across daemon restarts.

Changes:

  • Removed the systemd ExecStartPre=/usr/bin/sleep 2 workaround and the custom StartLimit* settings from the user unit.
  • Added a blocking wait in asusd-user for the xyz.ljones.Asusd D-Bus name owner to appear (with a 30s timeout), then proceeds to interface discovery.
  • Switched some stdout prints to structured logging and added the log dependency.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
data/asusd-user.service Removes fixed sleep and restart limit overrides so startup ordering is handled in-code.
asusd-user/src/error.rs Adds a dedicated timeout error for the new D-Bus wait path.
asusd-user/src/daemon.rs Implements D-Bus name-owner wait before querying interfaces; changes startup output to log macros.
asusd-user/src/ctrl_anime.rs Replaces a println! error path with log::error!.
asusd-user/Cargo.toml Adds log as a workspace dependency for the new logging usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread asusd-user/src/daemon.rs Outdated
Comment thread asusd-user/src/daemon.rs Outdated
Comment thread asusd-user/src/daemon.rs
@scardracs
scardracs force-pushed the bugfix/issue-183-hotkeys-startup branch 2 times, most recently from 9b0bc7f to 20cb5f4 Compare July 22, 2026 09:20
@scardracs scardracs changed the title fix(asusd-user): wait dynamically for system daemon on D-Bus (resolves #183) fix(asusd-user): wait dynamically for system daemon on D-Bus Jul 23, 2026

@Ghoul4500 Ghoul4500 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this last change fr

Comment thread asusd-user/src/daemon.rs
@scardracs
scardracs force-pushed the bugfix/issue-183-hotkeys-startup branch from 20cb5f4 to 060d6dd Compare July 23, 2026 16:34
@Ghoul4500
Ghoul4500 merged commit 2efcfd9 into OpenGamingCollective:main Jul 23, 2026
@scardracs
scardracs deleted the bugfix/issue-183-hotkeys-startup branch July 24, 2026 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants