elkowar / eww

ElKowars wacky widgets
https://elkowar.github.io/eww
MIT License
9.22k stars 380 forks source link

[BUG] Button-Onclick scripts seem to early-exit after dmenu-call #626

Open Giftzwerg02 opened 1 year ago

Giftzwerg02 commented 1 year ago

Checklist before submitting an issue

Description of the bug

I am unable to make use of any dmenu scripts (custom made or something like networkmanager_dmenu). The dmenu prompt is shown as expected and if I pipe the output into a file (e.g. echo "test" | dmenu > output.txt then "test" is written into output.txt after I hit enter (as expected). Yet no statements after that line are executed at all (networkmanager_dmenu also prompts but doesn't make use of the user-input).

I managed to minimize the bug behaviour to the following eww.yuck file:

(defwindow bar (button :onclick "networkmanager_dmenu" "test"))

Reproducing the issue

Expected behaviour

Have the script execute lines after the dmenu statement as well.

Additional context

No response

buffet commented 1 year ago

The issue here is that there is a timeout for the command, that's set to 200ms by default.

As a workaround you can choose a bigger timeout (like a trillion seconds), which will in practice not be an issue.

It probably makes sense to introduce some way to disable the timeout in the long run.

Giftzwerg02 commented 1 year ago

Yup, that fixed it, thank you!

But something I still have to mention: Since I opened the issue here I also found that something like "sleep 1" before a command causes the same issue (which makes sense with your explanation), but I also let somebody try a script (like "sleep 1" and on the next line "firefox") and on his side it worked... did this timeout setting maybe get introduced recently?

buffet commented 1 year ago

I think it's been introduced with 9588f31861d1dd081c68acf56ac1215286832dbb (around August last year), so it's been around for a while.

TheJay-Jay commented 8 months ago

Hey there, this fixes it for me;

(defwidget terminal [] (box :orientation "horizontal" :space-evenly "false" :halign "start" (button :timeout "1000ms" :onclick "kitty &" "kitty"
) ) )

It seems throwing in an "&" after the command stops the timeout.

Sergih28 commented 7 months ago

Hey there, this fixes it for me;

(defwidget terminal [] (box :orientation "horizontal" :space-evenly "false" :halign "start" (button :timeout "1000ms" :onclick "kitty &" "kitty" ) ) )

It seems throwing in an "&" after the command stops the timeout.

That doesn't fully work for me, but I added a & sleep 1 after my command and that made the trick. In my case this is not a dmenu issue, my problem is that the terminal closes right after running the onclick command. I could see it a blink for a few ms and that my command was being executed before this hack, that's how I knew the command was working.