-
Notifications
You must be signed in to change notification settings - Fork 621
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
[WIP] Execute custom user commands or scripts on a variety of rofi events #2053
base: next
Are you sure you want to change the base?
Conversation
…s: entry selected, entry accepted, menu canceled, menu error, mode changed, screenshot taken
this looks very neat. and simple to use too. exactly what i was going for. a settings option for adding sounds. i wanted to suggest espeak but wasnt sure if it was possible to implement read aloud options. thanks @giomatfois62 |
…entry index in selection_changed_user_callback
Can the options be documented in the manpages? then I will merge this. |
Sure, do you prefer a section in the general rofi page or a different file like for xdg thumbnails? |
I think I prefer a separate. It is additional functionality, the main manpage is already long enough. |
Hi guys! I have tried the patch and noticed that |
I tried the scripts to play sound with the "window" modi and they work, window name will be passed replacing "{entry}". |
So from what I can see, using |
@1337kerberos now I understand, I guess it could be done with some effort, here I added the call for the custom script on entry accepted, you can see that the expression "{entry}" is replaced by the currently selected text, you could easily add a "{window}" there since helper_parse_setup supports multiple arguments, but the x11 window id is not easy to get there, there's a separate c file with all that logic (source/modes/window.c) and it's kind of hidden from the generic view code. |
@giomatfois62 Thanks for the details; one more question - how do you debug rofi? ;) Ok, I have an idea, install an Ubuntu VM and then use a remote gdb to debug it, Update: I have hacked around the issue by adding a script to reposition the active window after rofi, |
It's not easy to debug since it grabs the keyboard input and blocks it when the process is paused, take a look at this doc page rofi-debugging |
This pull request addresses issue #2032, making it possible to execute custom user commands or scripts on a variety of rofi events. The following events are covered for now:
Custom commands can be specified from command line as follows:
Here's an example bash script to react to "selected entry change" playing a sound:
Arguments to user commands enclosed in curly braces will be replaced with corresponding values (e.g. {entry} with currently selected or accepted entry, {error} with error text etc.). Among other things, this allows the use of a synthetic speaker (like espeak or piper) to read aloud rofi interactions. Here's an example bash script to read aloud currently selected entries using espeak:
The use of "coproc" for playing sounds with aplay is suggested, as the first example script shows, otherwise the rofi process will wait for sounds to end playback before exiting, and that can be annoying if someone concatenate multiple rofi menus (cough cough..).
Some things I don't like with current implementation:
For the callback names (on-selection-changed etc.) I tried to be descriptive enough without making them too long, but I'm certainly open to different suggestions, as well as for other rofi events worth provisioning with custom commands.
My first experiments were made using an actual C audio library integrated in rofi, but this implementation coupled with simple bash scripts does the job as well and is much more flexible.
Let me know what you think.