Pdmenu is a tool written by Joey Hess which allows the creation of a simple menu in a terminal (console) window. It is in his list of less active projects, and the latest version is dated 2014, but it seems to be quite complete and useful as it is.
I like simple menus. As a Sysadmin in my last job I used one on the OpenVMS system I managed which helped me run the various periodic tasks I needed to run - especially the less frequent ones - without having to remember all of the details.
I do the same on my various Linux systems, and find that
pdmenu is ideal for the task.
pdmenu in the Debian repositories (I run Debian Testing), and it was very easily installed. The C source is available as a tarfile, though I haven’t tried building it myself.
pdmenu at a command prompt will invoke the utility. It uses the file
/etc/pdmenurc as its default configuration file, and this generates a menu with a demonstration of some of its features.
This is not particularly useful but it can be overridden by creating your own configuration, which by default is in
pdmenu command itself takes a configuration file as an argument, so there is plenty of flexibility.
The configuration file
I use the
~/.pdmenurc file at present, so I will talk about that. This file contains definitions (commands) that look like this example from the
pdmenu manual page:
#Set a pleasing color scheme. color:desktop:blue:blue color:title:blue:white color:base:blue:white #this is a comment menu:main:Main Menu:Things to do at foobar show:_Games..::games exec:_Mail::pine exec:_News::slrn -C exec:_WWW::lynx exec:_Irc::irc exec:_Directory Listing:display:ls -l exec:_Who's online?:truncate:w exec:_Finger:edit,truncate:finger ~finger who?:~ nop exit:E_xit menu:games:Games:Some text-based games exec:_Tetris for Terminals::/usr/games/tt exec:_Adventure:pause:/usr/games/adventure exec:_Zork:pause:/usr/games/zork nop exit:_Back to main menu..
- The first block of lines use
colorcommands to set the colours of the menu display.
The next block defines a menu with the
menucommand. The menu’s internal name is
main, and its title is ‘Main Menu’. The text “Things to do at foobar” is displayed at the bottom of the screen as help text.
- The first item in the menu is a link to another menu called ‘Games’ which is defined later in the file.
- The underscore before the ‘G’ makes it a hot-key which is highlighted
execcommand makes a menu entry which runs a command
nopcommand leaves a line in the menu (with optional text)
exitcommand exits the current menu to the level above
Top level menu and sub-menu from the above example
There is quite a lot more to be said about
pdmenu but I’ll leave you to investigate further if it seems interesting to you.
However, I will mention the
group command and how it can be used to create dynamic menus, just to give you some idea of the power and flexibility of this utility.
I am using
pdmenu to help manage various administrative tasks I do for HPR. The latest menu I have built helps me intercept the notes from newly uploaded shows, which I check and edit if necessary, generate HTML if needed and then upload the result for incorporation.
I use a number of scripts for all of this which I will not go into here. I get alerted when a new show is in the process of being uploaded. I have a tool that checks to see if the upload has finished, and when it is complete I grab the notes and save a local copy. I then process these notes as necessary.
Here is the menu definition:
menu:showsubmission:HPR Show Submission:Deal with incoming shows exec:_Show status:pause:~/HPR/Show_Submission/NS_test exec:_Rsync new show notes::~/HPR/Show_Submission/sync_hpr exec:_Copy notes:pause:~/HPR/Show_Submission/copy_shownotes nop:-- group:_Process unprocessed shownotes exec::makemenu:~/HPR/Show_Submission/makemenu show:Process notes::process remove:::process endgroup nop:-- exit:E_xit HPR Show Submission
The interesting bit is the
group command. It invokes an
exec with the
makemenu flag. This takes the output of the group and makes a menu out of it. I call a script I wrote called
makemenu (not very originally!) which works out which files need processing and offers a menu to do it. The menu is called
process, and the
show command is used to display it. Once finished the menu is deleted with the
I have made an example using dummy show number 2465 to demonstrate the base menu and the dynamically generated sub-menu. I’m using the same colours as the previous example.
Top level menu and sub-menu from my
Here’s what my
makemenu script generates to make the sub-menu:
$ ./makemenu menu:process:Process notes for 2465:Process notes for 2465 exec:Show _raw (2465):pause:~/HPR/Show_Submission/do_show 2465 exec:_Parse raw (2465):pause:~/HPR/Show_Submission/do_parse 2465 exec:_Edit notes (2465):pause:~/HPR/Show_Submission/do_vim 2465 exec:Run _Pandoc (2465):pause:~/HPR/Show_Submission/do_pandoc 2465 exec:Run _Midori (2465):pause:~/HPR/Show_Submission/do_midori 2465 exec:_Upload HTML (2465):pause:~/HPR/Show_Submission/do_upload 2465 exit:E_xit processing for 2465
This system is under development so may well change in the light of experience.