-
Notifications
You must be signed in to change notification settings - Fork 626
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Execute custom user commands or scripts on a variety of rofi ev…
…ents (#2053) * Implemented custom user command execution on the following menu events: entry selected, entry accepted, menu canceled, menu error, mode changed, screenshot taken * fixed different signedness comparison warning and compare unfiltered entry index in selection_changed_user_callback * track previously selected line in RofiViewState * added documentation about custom scripts to run on certain actions --------- Co-authored-by: Matteo <[email protected]>
- Loading branch information
1 parent
5870040
commit bc67d8a
Showing
8 changed files
with
239 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# rofi-actions(5) | ||
|
||
## NAME | ||
|
||
**rofi-actions** - Custom commands following interaction with rofi menus | ||
|
||
## DESCRIPTION | ||
|
||
**rofi** allows to set custom commands or scripts to be executed when some actions are performed in the menu, such as changing selection, accepting an entry or canceling. | ||
|
||
This makes it possible for example to play sound effects or read aloud menu entries on selection. | ||
|
||
## USAGE | ||
|
||
Following is the list of rofi flags for specifying custom commands or scripts to execute on supported actions: | ||
|
||
`-on-selection-changed` *cmd* | ||
|
||
Command or script to run when the current selection changes. Selected text is forwarded to the command replacing the pattern *{entry}*. | ||
|
||
`-on-entry-accepted` *cmd* | ||
|
||
Command or script to run when a menu entry is accepted. Accepted text is forwarded to the command replacing the pattern *{entry}*. | ||
|
||
`-on-mode-changed` *cmd* | ||
|
||
Command or script to run when the menu mode (e.g. drun,window,ssh...) is changed. | ||
|
||
`-on-menu-canceled` *cmd* | ||
|
||
Command or script to run when the menu is canceled. | ||
|
||
`-on-menu-error` *cmd* | ||
|
||
Command or script to run when an error menu is shown (e.g. `rofi -e "error message"`). Error text is forwarded to the command replacing the pattern *{error}*. | ||
|
||
`-on-screenshot-taken` *cmd* | ||
|
||
Command or script to run when a screenshot of rofi is taken. Screenshot path is forwarded to the command replacing the pattern *{path}*. | ||
|
||
### Example usage | ||
|
||
Rofi command line: | ||
|
||
```bash | ||
rofi -on-selection-changed "/path/to/select.sh {entry}" \ | ||
-on-entry-accepted "/path/to/accept.sh {entry}" \ | ||
-on-menu-canceled "/path/to/exit.sh" \ | ||
-on-mode-changed "/path/to/change.sh" \ | ||
-on-menu-error "/path/to/error.sh {error}" \ | ||
-on-screenshot-taken "/path/to/camera.sh {path}" \ | ||
-show drun | ||
``` | ||
|
||
Rofi config file: | ||
|
||
```css | ||
configuration { | ||
on-selection-changed: "/path/to/select.sh {entry}"; | ||
on-entry-accepted: "/path/to/accept.sh {entry}"; | ||
on-menu-canceled: "/path/to/exit.sh"; | ||
on-mode-changed: "/path/to/change.sh"; | ||
on-menu-error: "/path/to/error.sh {error}"; | ||
on-screenshot-taken: "/path/to/camera.sh {path}"; | ||
} | ||
``` | ||
|
||
### Play sound effects | ||
|
||
Here's an example bash script that plays a sound effect using `aplay` when the current selection is changed: | ||
|
||
```bash | ||
#!/bin/bash | ||
|
||
coproc aplay -q $HOME/Music/selecting_an_item.wav | ||
``` | ||
|
||
The use of `coproc` for playing sounds is suggested, otherwise the rofi process will wait for sounds to end playback before exiting. | ||
|
||
### Read aloud | ||
|
||
Here's an example bash script that reads aloud currently selected entries using `espeak`: | ||
|
||
```bash | ||
#!/bin/bash | ||
|
||
killall espeak | ||
echo "selected: $@" | espeak | ||
``` |
This file contains 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
This file contains 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
This file contains 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
This file contains 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