Waybar icon indicating copy to clipboard operation
Waybar copied to clipboard

Left-click on any Waybar element triggers previous on-click after right-click on custom module

Open xdpetx opened this issue 7 months ago • 2 comments

Hello,

I'm experiencing an issue with Waybar where a left-click on any part of the Waybar (including other modules or empty space) will re-trigger the on-click action of a custom module, specifically after a right-click was previously performed on that same custom module.

My Setup:

Waybar Version: 0.9.17-2

Window Manager: Sway

Custom Module Configuration (~/.config/waybar/customs.jsonc excerpt):

"custom/shutdown": { "format": " 󰂭 exit ", "tooltip": false, "on-click": "~/.config/waybar/scripts/exitsway.sh", "on-click-right": "sway reload", "tooltip-format": "Beenden" },

exitsway.sh script content:

#!/bin/bash

title="exit sway" msg="nach 10 Sekunden wird sway beendet"

zenity --question --title="$title" --text="$msg" --timeout=10 retval=$?

if test "$retval" -eq 1; then notify-send "exit sway" "Abbruch sway wird nicht beendet" -t 3000 exit 0 else notify-send "exit sway" "sway wird beendet" -t 3000 fi

Cleanup system

Reset pid Flags for Panel, Statuszeile und Sidebar

rm /tmp/waybar_* rm /tmp/sway_*

User-specific cleanup

waydroid session stop sleep 1 waydroid status sleep 1 swaymsg exit

exit 0

Steps to reproduce the issue:

Ensure Waybar is running.

Right-click on the "shutdown" custom module in the Waybar. This executes sway reload.

After sway reload completes, left-click on any other element or an empty space on the Waybar.

The exitsway.sh script (the on-click action of the shutdown module) is unexpectedly triggered again.

Observed Debug Output (waybar --log-level debug): (This output was captured after performing the right-click on the module, followed by a left-click elsewhere on the Waybar.)

[2025-06-07 23:23:36.415] [info] Bar configured (width: 1600, height: 30) for output: VGA-1 [2025-06-07 23:24:49.920] [debug] Added child to reap list: 8626 [ { "success": true } ] [2025-06-07 23:24:50.954] [debug] Received SIGCHLD in signalThread [2025-06-07 23:24:50.954] [debug] Reaped child with PID: 8626 [2025-06-07 23:24:55.614] [debug] Added child to reap list: 8758 [2025-06-07 23:24:57.486] [debug] Received SIGCHLD in signalThread [2025-06-07 23:24:57.486] [debug] Reaped child with PID: 8758

Explanation of debug output:

PID 8626 corresponds to the sway reload command.

PID 8758 corresponds to the exitsway.sh script.

The log shows that after sway reload (PID 8626) completes, a subsequent left-click (even on unrelated Waybar areas) causes Waybar to spawn exitsway.sh (PID 8758), indicating the on-click action of the custom/shutdown module is re-triggered.

Troubleshooting attempted:

Adding && sleep 0.1 after sway reload in on-click-right did not resolve the issue.

Using pkill -SIGUSR1 waybar after sway reload caused Waybar to crash completely, so this approach was not viable.

This issue seems to be related to Waybar's internal event handling after an on-click-right action, where the module's state or focus is not properly reset.

Thank you for your help!

xdpetx avatar Jun 07 '25 22:06 xdpetx

#3749 and #2166, I think.

RobertMueller2 avatar Jun 08 '25 14:06 RobertMueller2

"custom/shutdown": {
	"format": " 󰂭 exit ",
	"tooltip": false,
	"on-click": "~/.config/waybar/scripts/exitsway.sh",
	"on-click-right": "notify-send 'custom shutdown: ' 'on click right'", #this works
	//"on-click-right": "~/.config/waybar/scripts/sway_reload.sh",
	//"on-click-right": "sway reload",
	//"on-click-right": "swaymsg exec 'sway reload'",
	"tooltip-format": "Beenden"

}, It seems this issue occurs only when sway reload is called, regardless of how it's invoked.

xdpetx avatar Jun 10 '25 08:06 xdpetx