Chapter 9. Configuring the menus

Table of Contents
9.1. Basic Menu Syntax
9.2. Menu Keywords
9.3. Dynamic Menus

The root menu is what you get when you (by default- See the Mouse Bindings section) left-click on the root window (also called the desktop). You can also configure the window menu, which you get when you right-click on a window title.

9.1. Basic Menu Syntax

As previously indicated, the root menu follows the rules defined in Common Syntax. There aren't many possible options, and they're all either within the main menu, or within a submenu. This is all handled by a single file.

Here's an example ~/.pekwm/menu file:


# Menu config for pekwm

# Variables
$TERM = "xterm -fn fixed +sb -bg black -fg white"

RootMenu = "Pekwm" {
        Entry = "Term" { Actions = "Exec $TERM &" }
        Entry = "Emacs" { Actions = "Exec $TERM -title emacs -e emacs -nw &" }
        Entry = "Vim" { Actions = "Exec $TERM -title vim -e vi &" }
        Separator {}
        Submenu = "Graphics" {
                Entry = "Gimp" { Actions = "Exec gimp &" }
                Entry = "Gv" { Actions = "Exec gv &" }
                Entry = "Xpdf" { Actions = "Exec xpdf &" }
        }
        Submenu = "Mm" {
                Entry = "Xmms" { Actions = "Exec xmms &" }
                Entry = "MPlayer" { Actions = "Exec mplayer &" }
        }
        Submenu = "Utils" {
                Entry = "XCalc" { Actions = "Exec xcalc &" }
                Entry = "XMan" { Actions = "Exec xman &" }
        }
        Submenu = "WwW" {
                Entry = "Dillo" { Actions = "Exec dillo &" }
                Entry = "Konqueror" { Actions = "Exec konqueror www.google.com &" }
                Entry = "Mozilla" { Actions = "Exec mozilla &" }
                Entry = "Mutt" { Actions = "Exec $TERM -title mutt -e mutt &" }
        }
        Separator {}
        Submenu = "Pekwm" {
        Entry = "Reload" { Actions = "Reload" }
        Entry = "Restart" { Actions = "Restart" }
        Entry = "Exit" { Actions = "Exit" }
                Submenu = "Others" {
                        Entry = "Xterm" { Actions = "RestartOther xterm" }
                        Entry = "Twm" { Actions = "RestartOther twm" }
                }
                Submenu = "Themes" {
                        Entry { Actions = "Dynamic ~/.pekwm/scripts/pekwm_themeset.pl" }
                }
        }
}

WindowMenu = "Window Menu" {
        Entry = "(Un)Stick" { Actions = "Toggle Sticky" }
        Entry = "(Un)Shade" { Actions = "Toggle Shaded" }

        Submenu = "Maximize" {
                Entry = "Full" { Actions = "Toggle Maximized True True" }
                Entry = "Horizontal" { Actions = "Toggle Maximized True False" }
                Entry = "Vertical" { Actions = "Toggle Maximized False True" }
        }
        Submenu = "Stacking" {
                Entry = "Raise " { Actions = "Raise" }
                Entry = "Lower" { Actions = "Lower" }
                Entry = "Always On Top " { Actions = "Toggle AlwaysOnTop" }
                Entry = "Always Below" { Actions = "Toggle AlwaysBelow" }
        }
        Submenu = "Decor" {
                Entry = "Decor" { Actions = "Toggle DecorBorder; Toggle DecorTitlebar" }
                Entry = "Border" { Actions = "Toggle DecorBorder" }
                Entry = "Titlebar" { Actions = "Toggle DecorTitlebar" }
        }
        SubMenu = "Send To" {
                Entry = "Workspace 1" { Actions = "SendToWorkspace 1" }
                Entry = "Workspace 2" { Actions = "SendToWorkspace 2" }
                Entry = "Workspace 3" { Actions = "SendToWorkspace 3" }
                Entry = "Workspace 4" { Actions = "SendToWorkspace 4; GoToWorkspace 4" }
        }
        SubMenu = "Toggle Skip" {
                Entry = "Menus" { Actions = "Toggle Skip Menus" }
                Entry = "Focus Toggle" { Actions = "Toggle Skip FocusToggle" }
                Entry = "Snap" { Actions = "Toggle Skip Snap" }
        }
        Entry = "Iconify " { Actions = "Toggle Iconified" }
        Entry = "Close" { Actions = "Close" }
        Entry = "Kill " { Actions = "Kill" }
}

9.2. Menu Keywords

Here are the different elements that can be used in your root menu file.

Root Menu Elements:

Submenu (Name)

Begins a submenu. 'name' is what will appear in the root menu for the entry.

Name (Name)

Alternative way of saying Submenu = "name" {. Start the submenu with Submenu { Name = "name" to use this feature.

Entry (Name)

Begins a menu entry. 'Name' is the text shown in the menu for this entry.

Actions (Action)

Run an action. 'Action' is the action(s) to run. Most actions listed in Keys/mouse actions will also work from the root and window menus.

Separator

Adds a separator to the menu.

Menu Actions:

Exec

Exec makes pekwm to execute the command that follows it. Make sure the program gets backgrounded. Put an '&' at the end of the action if it doesn't do this on it's own.

Reload

When this is called, pekwm will Re-read all configuration files without exiting.

Restart

This will cause pekwm to exit and re-start completely.

RestartOther

Quits pekwm and starts another application. The application to run is given as a parameter.

Exit

Exits pekwm. Under a normal X setup, This will end your X session.

9.3. Dynamic Menus

It is possible to use dynamic menus in pekwm, that is menus that regenerate themself whenever the menu is viewed. This is done with the Dynamic keyword.

To use this feature, you need to put a dynamic entry in the ~/.pekwm/menu file with a parameter that tells pekwm what file to execute to get the menu. This file can be of any language you prefer, the main thing is that it outputs valid pekwm menu syntax inside a Dynamic {} section. The syntax of dynamic entry looks like this:

Entry = "" { Actions = "Dynamic /path/to/filename" }

The input from a program that creates the dynamic content should follow the general menu syntax encapsulated inside a Dynamic {} section. Variables have to be included inside the dynamic menu for them to work. A simple script to give pekwm dynamic menu content would look like this:

#!/bin/bash
output=$RANDOM # gets a random number

echo "Dynamic {"
echo " Entry = \"$output\" { Actions = \"Exec xmessage $output\" }"
echo "}"

This script would output something like:

Dynamic {
 Entry = "31549" { Actions = "Exec xmessage 31549" }
}