Skip to content

shortcuts_menu

fdev31 edited this page Feb 10, 2024 · 42 revisions

Presents some menu to run shortcut commands. Supports nested menus (categories / submenus).

Configuration example:

[shortcuts_menu]
parameters = "--prompt-text 🍰 --fuzzy-match true"
engine = "rofi"

[shortcuts_menu.entries]
"Open Jira ticket" = 'open-jira-ticket "$(wl-paste)"'
"Show Jira cheatsheet" = "xdg-open https://cheatography.com/rhorber/cheat-sheets/jira-text-formatting-notation/"
"Local WIKI" = "xdg-open http://localhost:8000/"
"Serial USB Term" = "kitty miniterm --raw --eol LF /dev/ttyUSB* 115200"
Custom = "~/scripts/custom.sh"
Relayout = "pypr relayout"
"Hyprland socket" = 'kitty  socat - "UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock"'
"Hyprland logs" = 'kitty tail -f /tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/hyprland.log'

Note

Added in version 1.9.0

Command

  • menu [name]: shows a list of options. If "name" is provided it will show the given sub-menu

Configuration

entries

Defines the menu entries.

[shortcuts_menu.entries]
"entry 1" = "command to run"
"entry 2" = "command to run"

Submenus can be defined too (there is no depth limit):

[shortcuts_menu.entries."My submenu"]
"entry X" = "command"

[shortcuts_menu.entries.one.two.three.four.five]
foobar = "ls"

Advanced usage (since version 1.10)

Instead of navigating a configured list of menu options and running a pre-defined command, you can collect various variables (either static list of options selected by the user, or generated from a shell command) and then run a command using those variables. Eg:

"Play Video" = [
    {name="video_device", command="ls /dev/video*"},
    {name="player",
        options=["mpv", "guvcview"]
    },
    "[player] [video_device]"
]

"Ssh" = [
    {name="action", options=["htop", "uptime", "sudo halt -p"]},
    {name="host", options=["gamix", "gate", "idp"]},
    "kitty --hold ssh [host] [action]"
]

You must define a list of objects, containing:

  • name: the variable name
  • then the list of options, must one of:
    • options for a static list of options
    • command to get the list of options from a shell command's output

The last item of the list must be a string which is the command to run. Variables can be used enclosed in [].

engine (optional)

Not set by default, will autodetect the available menu engine.

Supported engines:

  • tofi
  • rofi
  • wofi
  • bemenu
  • dmenu

Note

If your menu system isn't supported, you can open a feature request

In case the engine isn't recognized, engine + parameters configuration options will be used to start the process, it requires a dmenu-like behavior.

parameters (optional)

Extra parameters added to the engine command, the default value is specific to each engine.

Hints

Multiple menus

To manage multiple distinct menus, always use a name when using the pypr menu <name> command.

Example of a multi-menu configuration:

[shortcuts_menu.entries."Basic commands"]
"entry X" = "command"
"entry Y" = "command2"

[shortcuts_menu.entries.menu2]
# ...

You can then show the first menu using pypr menu "Basic commands"

Clone this wiki locally