Feature request: allow on-click commands in custom modules to run detached from Waybar’s session
Currently, on-click commands in custom modules run synchronously within Waybar’s process group.
This behavior can cause issues for commands that start long-running or session-dependent processes (e.g. screen recorders).
Problem
Because the on-click handler runs synchronously and inherits Waybar’s session, commands like gpu-screen-recorder may hang or fail to start until the handler returns. Workarounds like setsid bash -c '...' solve this, but they’re cumbersome and inconsistent.
Proposed solution
Add a configuration option to let users explicitly choose detached behavior, e.g.:
"on-click-detached": true
or
"on-click-mode": "detached" | "sync" | "async"
Benefits
- Backward-compatible with existing configurations
- Prevents UI blocking or session inheritance issues for long-running scripts
- Cleaner and safer than requiring setsid in user configs
#Example
"custom/screenrecord": {
"format": "⏺",
"on-click": "omarchy-cmd-screenrecord",
"on-click-detached": true
}
Environment
- Waybar version: v0.14.0
- Desktop: Hyprland / Sway
- Example command: gpu-screen-recorder
Additional notes
Observed while integrating omarchy-cmd-screenrecord. Detaching the process manually with setsid fixes the issue completely.
#workaround:
"custom/screenrecording-indicator": {
"on-click": "setsid bash -c 'omarchy-cmd-screenrecord output'"
"exec": "$OMARCHY_PATH/default/waybar/indicators/screen-recording.sh",
"signal": 8,
"return-type": "json"
}
The same result can be achieved by delaying the 'on-click' command with sleep 0.2 or simmilars. An explanation can be visualized here: https://github.com/Alexays/Waybar/issues/1850#issuecomment-3465797044
This bug appears to share a root cause with the following Issues:
- #4609
- #1850