Comments (18)
Alternative: makoctl get_actions
or similar and then the user can script around its output.
from mako.
perhaps it would be better to add a configuration option for a choosing command to run. ie "--<whatever_want_to_call_it>=dmenu | rofi | whatever else" so that it is possible to support wayland native dmenu alternatives as they appear without a major rewrite.
from mako.
Sorry, my comment wasn't very clear. I was using this revision, which worked with dunstify --action=$'key\n\n,val\n\n' "Test"
but not with dunstify --action "key\n\n,val\n\n" "Test"
.
Both work now with the latest revision.
from mako.
Sorry for spamming, but I got it working by adding this line to mako config:
# ~/.config/mako/config
on-notify=exec makoctl menu wofi -d -p 'Choose Action: '
from mako.
Sure
from mako.
That would be nice too. Maybe we want both to be able to click on a notification to open the menu?
from mako.
In case it's useful to anyone, here's a script to handle notification actions with makoctl list
and makoctl invoke
. You can swap out rofi
for your preferred menu.
#! /bin/sh
while true
do
notifications=$(makoctl list)
actions=$(echo $notifications | jq '.data[0][0].actions.data')
if [ $(echo $actions | jq 'type') == "\"object\"" ] && [ $(echo $actions | jq 'length') != "0" ]; then
selection=$(echo $actions | jq 'values[]' | sed 's/" "/"\n"/g' | sed 's,.\(.*\).$,\1,g' | rofi -p "Select notification action" -dmenu)
if [ -n "$selection" ]; then
selection_key=$(echo $actions | jq -r --arg sel "$selection" 'to_entries[] | select(.value == $sel) | .key')
makoctl invoke $selection_key
fi
makoctl dismiss
fi
sleep 0.5
done
from mako.
Why is it wrapped in a while true ... sleep
?
Also, here's an alternate script, moving logic into jq
and using jq --exit-status
:
if actions_object="$(makoctl list | jq -re '.data[0][0].actions.data | if length > 0 then . else false end')"; then
makoctl invoke "$(jq -rn --arg sel "$(
jq -rn "$actions_object|values[]" |
rofi -dmenu -p "Select action: "
)" \
"$actions_object|to_entries[]|select(.value == \$sel).key"
)"
fi
However, I think this is possible without requiring the user to have jq (use busctl
without -j
), I'll work on a makoctl patch for --dmenu [dmenu-program] [[args]]
EDIT: It is possible, but doing it in POSIX sh without arrays makes it pretty clunky.
from mako.
Thanks @xPMo, your script is much cleaner. I was using the script as a background process to intercept actionable notifications, hence the while true ... sleep
.
Maybe --select-action
of --dmenu
?
EDIT: Here's what I'm using now. I added the check because rofi
can return without a value.
bindsym $mod+a exec mako-select-action rofi -dmenu -p "Select action"
#! /bin/sh
# mako-select-action
if actions_object="$(makoctl list | jq -re '.data[0][0].actions.data | if length > 0 then . else false end')"; then
selection="$(jq -rn --arg sel "$(
jq -rn "$actions_object|values[]" |
$@
)" \
"$actions_object|to_entries[]|select(.value == \$sel).key"
)"
if [ -n "$selection" ]; then
makoctl invoke $selection
fi
fi
from mako.
I found out during the course of writing the POSIX+no-jq variant that an action's key/value can have newlines or other difficult characters. busctl
will print them as C-style escapes, so what I did is leave them escaped (that means you see action with\nescaped newlines
in dmenu/rofi/etc.), and then fix them at the end:
if [ -n "$selection" ]; then
# The selection may contain C escape sequences, use printf %b to evaluate them.
# Due to how command substitutions occur, trailing newlines are mangled.
# Append another character to prevent this.
selection="$(printf '%b:' "$selection")"
makoctl invoke "${selection%?}"
fi
You can test this with dunstify --action=$'key\n\n,val\n\n'
.
from mako.
I do encourage anyone to review my POSIX sh script. I would like to contribute it in some form to mako, but it would be wise to make sure all the following hold:
The best way to handle multiple lists in sh is toEDIT: I found a better way. 🙂set --
them together, keeping track of the length/offset of each.- It correctly evaluates all C escape sequences provided by
busctl
. - The obtuse sh boilerplate is commented clearly enough for future maintenance.
- @emersion thinks it would make a good fit either in
makoctl
or separately ascontrib/bin/makomenu
.
from mako.
Your example isn't working for me. When I use dunstify --action "key\n\n,val\n\n" "Test"
with your escape functionality the action isn't received.
The same thing happens with your POSIX sh script. I think busctl
is actually expecting the escaped string.
EDIT: Correction, your example works but it breaks this case.
from mako.
your example works but it breaks this case.
Care to explain exactly what --action
breaks as a comment over there?
(In case you aren't aware, you can stay updated with any changes I make to the script:)
git clone 'https://gist.github.com/xPMo/462936ca0e86f3697a6365b2be02525d' makomenu
from mako.
Thanks @xPMo, your script is much cleaner. I was using the script as a background process to intercept actionable notifications, hence the
while true ... sleep
.Maybe
--select-action
of--dmenu
? EDIT: Here's what I'm using now. I added the check becauserofi
can return without a value.
bindsym $mod+a exec mako-select-action rofi -dmenu -p "Select action"
#! /bin/sh # mako-select-action if actions_object="$(makoctl list | jq -re '.data[0][0].actions.data | if length > 0 then . else false end')"; then selection="$(jq -rn --arg sel "$( jq -rn "$actions_object|values[]" | $@ )" \ "$actions_object|to_entries[]|select(.value == \$sel).key" )" if [ -n "$selection" ]; then makoctl invoke $selection fi fi
This is nice but what i am trying to acheive is
listing all notifications from history in rofi and showing the title and summary in the rofi msg box at time of scrolling through them and as soon as i select the notification it shows me the available action with it.
i am unable to figure out how to incoke action from the history of notifications
I mean how can i access the previous notification action
from mako.
Once a notification has been dismissed, I don't think it's possible to invoke an action on it per the spec. NotificationClosed
invalidates the notification ID.
from mako.
Once a notification has been dismissed, I don't think it's possible to invoke an action on it per the spec.
NotificationClosed
invalidates the notification ID.
Aah isn't there any hack around it to keep it available for the x amount of history notification?
from mako.
Hi, I'm new to hyprland and using mako as my notification daemon. I'd like to know if anyone knows how to handle bluetooth pairing confirmation? Mako is showing confirmation code but I have no way to click to confirm the pairing request. Any advise would be appreciated.
from mako.
I was able to confirm bluetooth connection using the example in the PR:
makoctl menu wofi -d -p 'Choose Action: '
But I had to manually type this in the terminal while the notification is still active. I'd like to know how to automatically invoke this using mako config.
from mako.
Related Issues (20)
- Is there a way to only blur the background of the notification and not the margin/padding? HOT 3
- App specific notification settings HOT 2
- makoctl history returns "type" : "aa{sv}" .... HOT 4
- Failed to connect to user bus: No such file or directory (2) HOT 1
- Improve README's Running section HOT 3
- Same ID on notification renders a new notification HOT 2
- Invoke default action also for restored notifications HOT 2
- No notification display after monitor hotplug
- pango markup doesn't work in title
- [Feature Request] Hover to dismiss
- menu opened from mako aren't killeable
- synchronous with notifi-send HOT 1
- Feature Request: Implement Different Border-Radius Options for Individual Corners HOT 1
- Mako cannot play sound if started automatically HOT 6
- JQ alternatives HOT 3
- ERROR: Neither source directory 'build' nor build directory None contain a build file meson.build HOT 1
- Implement an include option
- [Feature Request] Make "makoctl restore" also restore actions HOT 1
- Make `border-size` directional HOT 1
- Can't play a sound when a notification is opened HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mako.