rofi-actions(5)
π NAME π
rofi-actions β custom commands following interaction with rofi menus π
okay so this is the rofi-actions(5) page from the File Formats Manual, and it's literally about making rofi do cute lil extra things when you interact with it. bestie, it's giving "menu with a personality" β¨ no cap.
π DESCRIPTION π
rofi lets you set custom commands or scripts to run when certain actions happen in the menu β like when the selection changes, when you accept an entry, or when you cancel. π«Ά
so like, this makes it possible to play sound effects or read aloud menu entries on selection, for example. it's that simple, fr fr. π
π USAGE π
here's the list of rofi flags for specifying custom commands or scripts to execute on supported actions π
-on-selection-changedcmd β command or script to run when the current selection changes. selected text is forwarded to the command replacing the pattern{entry}. π¦-on-entry-acceptedcmd β command or script to run when a menu entry is accepted. accepted text is forwarded to the command replacing the pattern{entry}. β-on-mode-changedcmd β command or script to run when the menu mode (e.g.drun,window,ssh...) is changed. π-on-menu-canceledcmd β command or script to run when the menu is canceled. π-on-menu-errorcmd β 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-takencmd β 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: (iconic, honestly)
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: (same vibes, but in your config)
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 β it's giving "menu but make it a video game" π₯
#!/bin/bash
coproc aplay -q $HOME/Music/selecting_an_item.wav
π‘ the use ofcoprocfor playing sounds is suggested, otherwise the rofi process will wait for sounds to end playback before exiting. so like, don't skip thecoprocunless you want rofi to be dramatic and wait around. π
π£οΈ Read aloud π£οΈ
here's an example bash script that reads aloud currently selected entries using espeak β bestie, it's literally text-to-speech but make it rofi πΈ
#!/bin/bash
killall espeak
echo "selected: $@" | espeak
and that's the whole page, periodt. π
this was rofi-actions(5), from the File Formats Manual, brought to you by rofi β catch you in the next manpage, bestie π«Άβ¨π
π¦ where this page comes from
- alpine 3.24: rofi-doc 2.0.0-r0 Β· MIT
- ubuntu resolute: rofi 2.0.0-0.2 Β· MIT
- ubuntu stonking: rofi 2.0.0-0.2 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms