mako icon indicating copy to clipboard operation
mako copied to clipboard

Copy notification text with middle button click

Open jm355 opened this issue 2 years ago • 3 comments

I know the middle button click is configurable with on-button-middle=action, but is there any way to pass the notification text to wl-copy?

jm355 avatar Mar 01 '22 17:03 jm355

You'll need to use the $id shell variable, combined with makoctl list and jq, to get the notification text.

emersion avatar Mar 01 '22 17:03 emersion

Gotcha, I tried playing around with it for a while but it looks like makoctl list outputs a 2d array in .data and I'm not familiar enough with json or jq to know how to get it to do a nested loop and output the message body when the id == $id

jm355 avatar Mar 01 '22 19:03 jm355

I've been playing around with this idea and came across this thread. Anyway, the following appears to do the trick:

jq -r '.data|..|select(.id?.data=='$id')|.body|.data' | wl-copy

Note the above copies the "body" of the notification into the clipboard, depending on what you're trying to do, you may want to change body to summary.

Unfortunately, I haven't figured out how to both copy the data and dismiss the notification, e.g. the following fails to dismiss the notification:

on-button-left=exec makoctl list | jq -r '.data|..|select(.id?.data=='$id')|.body|.data' | wl-copy; mackoctl dismiss -n $id

I'm probably missing something obvious.

lostmythread avatar Apr 18 '22 14:04 lostmythread