emersion / mako

A lightweight Wayland notification daemon
https://wayland.emersion.fr/mako
MIT License
2.17k stars 137 forks source link

What's the proper way to pass actions? #491

Closed chrisr87 closed 8 months ago

chrisr87 commented 8 months ago

I'm banging my head trying to get this to work but there doesn't seem to be much documentation for actions.

I'm using hyprland on arch linux.

I'm testing via notify-send notify-send -t 0 -A open='xdg-open https://www.google.com' -A open2='xdg-open https://www.yahoo.com' summary body

I have this in my config on-button-left=exec makoctl menu -n "$id" dmenu -p 'Select action: '

Nothing happens when I click the notification. But if I manually grab the id via makoctl list and run makoctl menu -n 123 dmenu -p 'Select action: ', it brings up the menu properly. Although, the actions themselves don't work.

I've tested on-button-left=exec xdg-open https://www.google.com and that seems to open up correctly. So I know that property works. I printed the $id to a log so I know that's being passed properly.

I also tried on-button-left=invoke-action open and nothing happens. I'm not even sure if that's correct. I read the documentation several times and I'm unclear of what's wrong here.

I also see this in the journal

mako[3448809]: cannot open display

Also built from git and get something different

using dmenu

cannot grab keyboard

The build from git does load the menu properly when using rofi, but the actions still don't do anything.

emersion commented 8 months ago

The notify-send syntax is -A [NAME=]Text. The -A flag doesn't include any command. Instead, it prints any invoked action.

chrisr87 commented 8 months ago

The notify-send syntax is -A [NAME=]Text. The -A flag doesn't include any command. Instead, it prints any invoked action.

I see. But does invoke-action not execute the action passed to it? What does invoke-action do? I see this example in the mako manpage

[app-name="some-app-id" actionable]
on-button-left=invoke-action mail-reply-sender

but it's missing some context. It seems to just print the action I give it so I'm not clear on what I'm supposed to use this for.

emersion commented 8 months ago

invoke-action sends back a signal to notify-send (or whatever app opened the notification) that the user has selected the action. It's up to the app that opened the notification to handle this signal and (in this case) execute a command.

chrisr87 commented 8 months ago

invoke-action sends back a signal to notify-send (or whatever app opened the notification) that the user has selected the action. It's up to the app that opened the notification to handle this signal and (in this case) execute a command.

Makes sense now. Thank you for explaining.