you are viewing a single comment's thread
view the rest of the comments
[–] 2 points 7 months ago*

It's actually quite neat. It is a three part archesta:

  1. i3 key binding, say, Super-l that triggers a script of mine.
  2. The script itself rofi-menu takes a single argument, a text "menu file" that describes the menu. Say, my-layouts.menu
  3. The menu file is super simple. It looks like this:
Menu Title
[shortcut] # <exit | stay> # <label> # <command>
[shortcut] # <exit | stay> # <label> # <command>
[shortcut] # <exit | stay> # <label> # <command>
...

The script parses this file and generates the menu.

  • shortcut is the key binding that will immediately trigger the menu item.
  • exit | stay defines whether the menu closes after the option is actioned (sometimes you wanna keep the menu open)
  • label is what you see in the menu
  • command is... well, the command

One more thing, if your hostname is "my_machine", and the menu file that you gave to my script is "my-layout.menu", then the script will actually prefer to use "my-layout.my_machine.menu" if it exists. So you can share your config across multiple machines and have them pick the appropriate menus depending on where it is ran.

A menu example could be:

Layouts
l # stay # Rotate Layout # i3-msg toggle all
f # exit # Toggre Floating # i3-msg floating toggle

So to change i3 layouts, I type:

  • Super-l (opens menu)
  • l rotate layout (rows, cols, tabs, stack) and keep the menu open. If I keep hitting l it will keep rotating.
  • Esc to close the menu.

To toggle the window floating:

  • Super-l (opens menu)
  • f to toggle floating. The menu closes immediately after.

If you are interested, I can share the script with you :)

  • source
  • parent