Skip to content

Alphare/simple-rofi-menu

Repository files navigation

Simple Rofi menu

What started as a < 20 lines script to make a simple power menu to use with Rofi.

Screenshot

screenshot.png

Install and usage

Simply download simple_rofi_menu.py and an example config file to the same directory. You can find examples in the example_configs/ folder.

If you want to use a different path for your config file, add an environment variable 'SRM_CONFIG_DIR' and set it to the path of the directory containing your srm_config.<extension> file. As of now, SRM supports YAML and JSON formats. SRM will look for the YAML one first, then the JSON one. If you intend on using a YAML configuration file, you will need to have PyYAML installed.

To use the menu with rofi, use:

rofi -show <name> -modi <name>:<path>/simple_rofi_menu.py.

Note: This script uses #!/usr/bin/env python3, it will fetch your current Python environment and look for Python 3. You can do pip3 install PyYAML --user to install PyYAML in your general Python environment.

Documentation

Menu

Positional arguments: *groups
Type: MenuGroup
As many groups as you want.

Keyword argument: numbered
Type: Boolean
Default: False
Auto-numbering of all menu items.

Keyword argument: index_start
Type: Integer
Default: 0
Index of the first menu item if numbered is True.

Keyword argument: index_format
Type: String
Default: "{item_index} {item_name}"
Format for updating each MenuItem if numbered is True, which must define {item_index} and {item_name}.

Keyword argument: separator
Type: String
Default: "---"
Separates menu groups.

MenuGroup

Positional arguments: *items
Type: MenuItem
As many items as you want.

MenuItem

Argument: name
Type: String
Name to be displayed in the menu.

Argument: command
Type: String
Command to be executed upon selecting this item