Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom module: click behavior #2166

Open
maximiliankaul opened this issue May 10, 2023 · 11 comments
Open

Custom module: click behavior #2166

maximiliankaul opened this issue May 10, 2023 · 11 comments

Comments

@maximiliankaul
Copy link

Hi,
I have a minimal custom module that should act as a simple button to click on and then execute some command (ignoring the result):

"custom/mymodule": {
      "format": "",
      "on-click": "stuff"
    }

This works fine, in the sense that the module shows up and my command is executed on click. However, there is some wired behavior as my command (stuff in the example snippet) is now also executed when clicking other areas (like the workspace selector) on the bar, too.
How can I fix this so that my command is only executed when the module is actually clicked on?
Thanks :)

@maximiliankaul maximiliankaul changed the title Custom: click behavior Custom module: click behavior May 10, 2023
@nathanchere
Copy link

I've noticed this too with creating a "custom/power" module. If you click it once, it hijacks any further clicks across the entire bar.

@nathanchere
Copy link

nathanchere commented May 17, 2023

One thing I've noticed is that it only happens on the custom/power module. The relevant part of my config:

{
    "custom/menu": {
        "format": "!",
        "tooltip": false,
        "on-click": "rofi -show run"
    },
    "custom/power": {
        "format": "⏻",
        "tooltip": false,
        "on-click": "~/.config/hypr/scripts/powermenu.sh"
    },& pkill waylogout
}

My guess it's something to do with what is returned by the on-click event, because it doesn't happen to my menu one and I change the on-click event of custom/power to also call rofi it works as expected, i.e. displays the menu but doesn't hijack future clicks.

Also powermenu.sh just wraps around a long-winded call to waylogout

@NTICompass
Copy link

I'm having a similar with custom/clipboard module I created.

    "custom/clipboard": {
        "exec": "~/bin/waybar-clipboard",
        "return-type": "json",
        "interval": "once",
        "format": "{icon}",
        "format-icons": {
                "empty": "󱘡",
                "full": "󰨸",
        },
        "on-click": "cliphist list | fuzzel -d | cliphist decode | wl-copy",
        "on-click-middle": "cliphist wipe; pkill -RTMIN+9 waybar", 
        "exec-on-event": true,
        "signal": 9,
    }, 

When I click on the module, I get fuzzel with a list of stuff in my clipboard. After picking one (or hitting escape), whenever I click on anything else in the bar, then fuzzel appears again. The only way to fix it is to right (or middle) click on something.

P.S. waybar-clipboard is:

#!/bin/bash    
    
LINES=$(cliphist list | wc -l)    
[[ $LINES -eq 0 ]] && ICON='empty' || ICON='full'    
    
jq --unbuffered --compact-output \    
        --arg title 'clipboard' \    
        --arg icon "$ICON" \    
        --arg items "$LINES item(s)" \    
        -n '{text: $title, alt: $icon, tooltip: $items}'  

@maximiliankaul
Copy link
Author

I made two changes and the problem seems to be solved for my configuration:

  • I added "tooltip": false,
  • I upgraded my system. I think there were some related package updates.

My tool (stuff in my initial example) does not print anything. I guess this was the problem and somehow adding tooltip or updating my packages (Arch Linux) fixed this issue for me.

@Kvn0l
Copy link

Kvn0l commented May 24, 2023

If you guys are using Hyprland, the click issue is related to #1850 & hyprwm/Hyprland#1348

@nathanchere
Copy link

Until that fix gets merged into main releases, the workaround for me for now is if you right-click anywhere on the bar it is still picked up by the blocking module but it then seems to reset whatever is causing all future clicks to be captured by the same module.

The tooltip fix recommended above didn't work for me.

@Kvn0l
Copy link

Kvn0l commented May 31, 2023

Until that fix gets merged into main releases, the workaround for me for now is if you right-click anywhere on the bar it is still picked up by the blocking module but it then seems to reset whatever is causing all future clicks to be captured by the same module.

The tooltip fix recommended above didn't work for me.

Have u tried this: hyprwm/Hyprland#1348 (comment) ?

@nathanchere
Copy link

Have u tried this: hyprwm/Hyprland#1348 (comment) ?

I've tried it, it sometimes works but it's really inconsistent. I can put a sleep value up to around 0.25 before the lag becomes annoyingly noticeable and it still sometimes doesn't work and I need to right-click on the bar to 'reset' from that captured state. So for now I'm preferring 'consistently broken' and right-clicking instead of 'consistently laggy and sometimes broken'.

@RichAyotte
Copy link

this bug also affects swaync ErikReider/SwayNotificationCenter#292

@voronind-com
Copy link

voronind-com commented May 8, 2024

Can confirm also happens to me on Sway 1.9.
This is my module:

"custom/display": {
	"exec": "swayscript monbar",
	"interval": 1,
	"return-type": "json",
	"on-click": "swayscript montoggle",
	"on-click-right": "swayscript vrrtoggle"
}

and the output for swayscript monbar: {"text": "󰍹", "tooltip": "Mon: on / Vrr: off"}

swayscript sends swaymsg commands to toggle power/freesync for predefined monitors.

Update: for me the only working fix was to add sleep delay before the click command: "on-click": "sleep 0.1 && swayscript montoggle",

@grimkor
Copy link

grimkor commented May 16, 2024

Can confirm also happens to me on Sway 1.9. This is my module:

"custom/display": {
	"exec": "swayscript monbar",
	"interval": 1,
	"return-type": "json",
	"on-click": "swayscript montoggle",
	"on-click-right": "swayscript vrrtoggle"
}

and the output for swayscript monbar: {"text": "󰍹", "tooltip": "Mon: on / Vrr: off"}

swayscript sends swaymsg commands to toggle power/freesync for predefined monitors.

Update: for me the only working fix was to add sleep delay before the click command: "on-click": "sleep 0.1 && swayscript montoggle",

Also on 1.9 and sleep 0.1 fixed my custom widget I was testing out below:

    "custom/test": {
        "exec": "swaymsg -t get_outputs | jq 'map(select(.name==\"eDP-1\"))' | jq 'map({active})' | jq '.[0]' | jq '. + {\"class\": .active|tostring }' | jq 'if .active == true then .text=\"ON\" else .text=\"OFF\" end' | awk '{printf $0}'",
        "on-click": "sleep 0.1 && swaymsg -t get_outputs | jq 'map(select(.name==\"eDP-1\"))' | jq 'map({active})' | jq '.[0]' | jq 'if .active == true then .value=\"disable\" else .value=\"enable\" end' | jq '.value' | xargs -I {} swaymsg output -s $SWAYSOCK eDP-1 {}",
        "interval": 1,
        "return-type": "json"
    }

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

No branches or pull requests

7 participants