Option to execute command instead of keybind for buttons - #2327
Open
seg-faulty wants to merge 4 commits into
Open
seg-faulty wants to merge 4 commits into
seg-faulty wants to merge 4 commits into
Conversation
Collaborator
|
I need to discuss if this is something we want to add, but a few remarks looking at the patch:
|
seg-faulty
force-pushed
the
button-exec-command
branch
from
September 1, 2026 14:41
4546742 to
79cf94a
Compare
Author
Collaborator
|
yeah, helper_* does a lot of the error handling for free 😄 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Currently, you can only have Rofi perform functions using buttons by setting them to perform a specific keybind, e.g. a button to paste the contents of the keyboard would have the
actionproperty set tokb-primary-paste. When clicked, it would perform the same function as the keybind it was set to.In
dmenumode, custom keybinds (kb-custom-X) terminate Rofi and return a value when pressed, starting from 10. For example, when "ALT-1" (the default keybind forkb-custom-1) is pressed when indmenu, a value of 10 is returned. This allows for the creation of scripts that execute commands on pressing these keybinds, e.g.In the above script, if you press ALT-1 you would get the output "Custom keybind 1", ALT-2 "Custom keybind 2", and any other keybind "Something else". You can map a button to a keybind using the
actionproperty and then make a script that executes a command on that keybind, and hence when the button is clicked that command will be run.However, this does not seem to be the case in
drunmode. When I press ALT-1 indrun, it just switches towindowmode and ALT-2 takes me back todrunmode. This means those who want to add custom buttons to theirdrunmenus, e.g. a lock button or a power off button, cannot do so.My commit fixes this by adding a new string property for buttons, known as
exec. Ifactionis not set on a button, Rofi instead looks for theexecproperty which contains a command, such as a program or shell script. When the button is clicked, Rofi will run the command using stdlib'ssystemfunction.An optional boolean property (default set to
false)exit-after-command, iftrue, will close Rofi upon the command's completion.For example:
When the button is clicked, xterm is launched in the background and Rofi will close.