Simple shell script that reads a json file and display the items as rofi menu entries.
Supports icon.
-
Make sure you have jq (Command-line JSON processor) utility installed (arch package).
-
Copy
rofi-json.sh
from this repo (or git clone and link) to your rofi's configuration folder (i.e.~/.config/rofi
) and make it executable (chmod +x rofi-json.sh
). -
Create your JSON file (you can check examples folder).
-
Launch
rofi
with-modi <NAME_OF_THE_MODE>:<PATH_OF_SCRIPT>/rofi-json.sh <JSON_FILE>
:
rofi -modi "My Apps":"~/.config/rofi/rofi-json.sh my_apps.json" -show "My Apps"
<JSON_FILE>
: you can specify an absolute path (or ~), or just leave the json file name if it is located in the same directory as the rofi-json.sh
file.
[
{
"name": "Google Chrome",
"command": "google-chrome-stable",
"icon": "google-chrome"
},
{
"name": "gnome-disks"
},
{
"name": "pavucontrol"
},
{
"name": "journalctl -xeaf",
"command": "urxvt -e bash -c 'journalctl -xeaf'"
}
]
command
key is optional. If not specified, the script will run name
's value.
icon
key is optional (Default: system-run
).
You can run rofi-json script with different json's files and create multiple modi's:
rofi \
-modi config:"~/.config/rofi/rofi-json.sh config.json","My Apps":"~/.config/rofi/rofi-json.sh my_apps.json" \
-show "My Apps"
Adapted from Myrmidon