How to add custom commands to Menu and SidePanels

In the previous article we learned how to customize the appearance of the menu and sidepanels, now it’s time to see how to add custom commands/launchers.
The menu, Sidepanels and most of the Mabox tools are built on the basis of jgmenu – simple, independent, contemporary-looking X11 menu, designed for scripting, ricing and tweaking. Thanks to this, we have great opportunities to adapt them to our needs.

Let’s see how we can add our own items…
First run Mabox Control Center and go to Menu/Sidepanels tab.

This is comfortable place to edit all CSV files and also to quickly preview changes.

Menu is defined in CSV format, each line is parsed into the following fields using comma as a field separator:

description,command,icon

icon field is optional – for example Left Sidepenel does not use it at all

Basic Launchers

Lets start by adding some simple launchers to the TOP area of Right Sidepanel:

  • Gimp
  • Inkscape
  • Blender
  • Firefox
The GIMP,gimp,gimp
Inkscape SVG Editor,inkscape,inkscape
Blender 3D,blender,blender
Firefox Browser,firefox,firefox

We can offcourse add parameters to commands/programs, for example:

Firefox,firefox maboxlinux.org forum.maboxlinux.org manual.maboxlinux.org,firefox

Can you guess what will happen when you use this launcher?

Commands in terminal

To run some commands in terminal use ^term():

Neofetch,^term(neofetch),terminal

Try it…. uuups it runs commands and quit terminal immadietely.
It is normal behaviour if command is not interactive. We can fix that using:

Neofetch,^term(neofetch;read),terminal

This time terminal is alive and waiting for any key.
We can also keep terminal alive by spawning default shell after non-interactive command.

Neofetch,^term(neofetch;$SHELL),terminal

Some more terminal commands for example… here with separator/title Updates:

^sep(Updates)
Check for Updates (repo and AUR),^term(yay)
Mirror refresh,^term(sudo pacman-mirrors --fasttrack 5)

The ^term() markup is quick and easy way to run commands in terminal. If you need more control over terminal, like geometry/title you can still use normal commands for that, like:

Weather forecast,terminator -T "Weather forecast" --geometry=1030x740 -e "curl wttr.in ; read"

Other commands

You can also add some commands that don’t need a terminal to run. For example consider two commands shipped by default with Mabox in Left Sidepanel:

Random ColorScheme,mb-setvar jgmenu_theme=$(basename -s .colorrc $(ls ~/.config/mabox/jgobthemes/*.colorrc | shuf -n 1));mb-jgtools places
Random Wallpaper,nitrogen --random /usr/share/backgrounds --set-scaled --save;mb-jgtools places

Directory/File browser

Let’s suppose you want to have quick access to some directories from the main menu, e.g. ~/.config and ~/.local. We can do that by adding pipemenu (dynamically generated menu). We add them into main menu just below Applications:

^sep(Dirs)
Configs,^pipe(jgbrowser ~/.config),folder
Local,^pipe(jgbrowser ~/.local),folder
^sep()
Home Directory,^pipe(jgbrowser ~),user-home

Separators

To add separators to menu, use:

^sep()             # will render as horizontal line
^sep(TITLE)        # will render as TITLE

Pango markup

Basic pango markup is allowed in description field.

<b> bold
<big> makes font relatively larger
<i> italic
<s> strikethrough
<sub> subscript
<sup> superscript
<small> makes font relatively smaller
<tt> monospace font
<u> underline

With a little effort, you can fit the Menu and Sidepanels in Mabox to your needs, I hope you like it.
There are a few more advanced options, such as submenu and dynamically generated pipemenu, but that’s a topic for a separate article.