jgmenututorial7
A step-by-step tutorial to jgmenu
Introduction
This tutorial aims to explain the usage of jgmenu through a set of lessons.
Table of contents
•
|
Lesson 1 - Get started |
|---|---|
•
|
Lesson 2 - Architecture |
•
|
Lesson 3 - Scripting with jgmenu |
•
|
Lesson 4 - Descriptions |
•
|
Lesson 5 - Icons |
•
|
Lesson 6 - Submenus |
•
|
Lesson 7 - XDG Application Menus |
•
|
Lesson 8 - Config Options |
•
|
Lesson 9 - Apprend/Prepend and Separators |
•
|
Lesson 10 - CSV generators |
•
|
Lesson 11 - Search |
Lesson 1 - Get started
After installing jgmenu, start the menu by running the following command
-
jgmenu_run
You should see a Linux/BSD system menu showing installed applications. See lesson 7 for further details.
Create a config file (~/.config/jgmenu/jgmenurc) by running
-
jgmenu_run init
Full details of config options are covered in jgmenu(1) (jgmenu.1.html).
By entering the interactive mode and then selecting `t', you can try some pre-defined templates/themes.
-
jgmenu_run init -i
There are a small number of configuration options which may need manual intervention in order for jgmenu to display correctly on your system.
position_mode-
There are several methods for positioning the menu. Try
fixed,ipc,centerandpointerto see what works best on your system. See jgmenu(1) for full details.
menu_margin_xandmenu_margin_y-
If your are using
position_mode=fixed, you may need to set these two variables. Depending on what window manager and panel you use, jgmenu may be able to automatically find a suitable vertical and horizontal position, so try without setting these variables first.
menu_halignandmenu_valign-
Again, depending on your system, you may need to manually specify horizontal and vertical alignment of the menu, but try without first.
Lesson 2 - Architecture
The design of jgmenu is very modular, providing a lot of flexibility in how it is used.
When jgmenu is started, two processes are run to produce the menu.
-
┌────────────────┐│ csv-generator │└────────────────┘|V┌────────────────┐│ graphical menu │└────────────────┘
The first process (csv-generator) produces the menu content, whereas the second generates the graphical menu.
jgmenu_run(1) (jgmenu_run.1.html) is a multi-purpose wrapper script which does the following is pseudo code:
-
if (jgmenu is already running)show menuelsestart a new instance of jgmenu
This makes it suitable for using with panels and keyboard shortcuts.
Lesson 4 - Descriptions
As you saw in the previous example, each line fed to stdin becomes a menu item. Any line containing two fields separated by a comma is parsed as description,command. Consider the following CSV menu data:
-
Terminal,xtermFile Manager,pcmanfm
This lets you give a more meaningful description to each menu item.
Lesson 5 - Icons
To display icons, you need to populate the third field. By default, jgmenu will obtain the icon theme from xsettings (if it is running) or tint2rc (if it exists). When running with the –simple argument, make sure that icon_theme is set to something sensible in your $HOME/.config/jgmenu/jgmenurc. Consider the following CSV menu data:
-
Browser, firefox, firefoxFile manager, pcmanfm, system-file-managerTerminal, xterm, utilities-terminalLock, i3lock -c 000000, system-lock-screenExit to prompt, openbox --exit, system-log-outReboot, systemctl -i reboot, system-rebootPoweroff, systemctl -i poweroff, system-shutdown
In the third field you can also specify the full path if you wish.
Options
In lesson 1 we discussed config options position_mode, menu_margin_x, menu_margin_y, menu_halign and menu_valign.
Here follow a few more options you may wish to explore. For full details, see jgmenu(1) (jgmenu.1.html).
Rofi style:
-
csv_no_dirs=1csv_single_window=1columns=2menu_width=600menu_valign=centermenu_halign=center
Synchronize colours, font and icons with tint2 panel
-
tint2_look=1
Lesson 9 - Apprend/Prepend and Separators
When using apps, pmenu or lx, you can add menu items to the top and bottom of the root menu by editing append.csv and/or prepend.csv in ~/.config/jgmenu. For example, try the following:
prepend.csv
-
Browser, firefox, firefoxFile manager, pcmanfm, system-file-managerTerminal, xterm, utilities-terminal^sep()
append.csv
-
^sep()Suspend, systemctl -i suspend, system-log-outReboot, systemctl -i reboot, system-rebootPoweroff, systemctl -i poweroff, system-shutdown
In these example we have used the markup ^sep(), which inserts a horizontal separator line. Similarly, ^sep(foo) inserts a text separator displaying “foo”
Lesson 10 - CSV generators
In previous lessons, we introduced the apps, lx and pmenu. These modules are referred to as “CSV generators” and are invoked as follows:
-
jgmenu_run <command>
Built-in “CSV generators” include: apps and ob
Optional “CSV generators” include: lx and pmenu
They are documented by a man page or a simple –help message.
-
man jgmenu-<command>jgmenu_run <command> --help
Here follow some examples of how they can be used.
Specify CSV generator in the config file by setting csv_cmd in ~/.config/jgmenu/jgmenurc
-
csv_cmd = pmenu
Specify CSV generator on the command line
-
jgmenu --csv-cmd="jgmenu_run pmenu"
Pipe the CSV output to jgmenu (using --simple to read from stdin)
-
jgmenu_run pmenu | jgmenu --simple
Create a pipemenu using ^pipe() markup. Consider this example
-
Terminal,xtermFile Manager,pcmanfm^pipe(jgmenu_run pmenu)
Lesson 11 - Search
jgmenu has search support, which can be invoked by just typing when the menu is open.
A search box can be inserted using widgets. For example, add this to ~/.config/jgmenu/prepend.csv:
-
@search,,3,3,150,20,2,left,top,auto,#000000 0,Type to Search
Make sure you adjust menu padding accordingly, for example
-
menu_padding_top=24
A search can also be invoked by associating a widget with a ^filter() command.
Releases
Unchanged in 3 releases since Debian 12 (Bookworm).