fix(asusd-user): wait dynamically for system daemon on D-Bus#185
Conversation
de02cd0 to
d277f67
Compare
Ghoul4500
left a comment
There was a problem hiding this comment.
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 |
d277f67 to
5fc5231
Compare
There was a problem hiding this comment.
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 2workaround and the customStartLimit*settings from the user unit. - Added a blocking wait in
asusd-userfor thexyz.ljones.AsusdD-Bus name owner to appear (with a 30s timeout), then proceeds to interface discovery. - Switched some stdout prints to structured logging and added the
logdependency.
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.
9b0bc7f to
20cb5f4
Compare
20cb5f4 to
060d6dd
Compare
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 2in the systemd user service). Becauseasusdtook longer than 2 seconds to register its name (xyz.ljones.Asusd) on D-Bus:asusd-userfailed to query the available D-Bus interfaces and crashed on start.StartLimitBurst=2in 200 seconds),asusd-userexhausted its startup attempts after two failures and was permanently disabled for the rest of the boot session, breaking all special hotkeys.Furthermore, keeping
StartLimitBurst=2meant 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:
Dynamic D-Bus Wait in
asusd-user(Commit 1):list_iface_blocking()at boot with a deterministic check of the D-Bus name owner status.xyz.ljones.Asusdhas no owner yet, the daemon subscribes to the D-Bus system daemon'sNameOwnerChangedsignal and blocks dynamically.asusdregisters its name and becomes ready,asusd-userbreaks the loop and continues its initialization. This is fully event-driven and resource-friendly.Systemd Service Clean Up & Restart Limits Removal (Commit 2):
ExecStartPre=/usr/bin/sleep 2fromdata/asusd-user.service, enabling the service to spawn instantly and wait cleanly in code.StartLimitInterval=200andStartLimitBurst=2options, 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— Updatesasusd-user/src/daemon.rswith the dynamic wait logic.fix(systemd): clean up user service startup and restart limits— Updatesdata/asusd-user.serviceto remove the sleep workaround and the start limit constraints.