[perl script] menu generator

First I wanna apologize if this is the wrong section or if a better solution has already been posted feel free to delete this post or move it…

I got lazy editing my menu everytime i uninstalled, installed something so I coded a generator in perl

it takes a directory of .desktop files and outputs all the data into a fvwm compatible menu format, separated by categories of the programs.
Keep in mind im not a programming guru so please check the output before using it in fvwm


Brief sample output:

m3th@l1quid ~ $ perl fvwm_menu.pl /usr/share/applications/
DestroyMenu MenuA
AddToMenu MenuA

  • MissingSubmenuFunction FuncFvwmMenuDirectory
  • “Astronomy” Popup MenuAstronomy
  • “Game” Popup MenuGame
  • “Graphics” Popup MenuGraphics
  • “KDE” Popup MenuKDE
  • “Network” Popup MenuNetwork
  • “Office” Popup MenuOffice
  • “Screensaver” Popup MenuScreensaver
  • “System” Popup MenuSystem

Astronomy Menu

DestroyMenu MenuAstronomy
AddToMenu MenuAstronomy

  • “Celestia” Exec /usr/bin/celestia

Game Menu

DestroyMenu MenuGame
AddToMenu MenuGame

  • “ZSNES” Exec zsnes
  • “TransGaming Cedega” Exec /usr/bin/cedega
  • “XQF” Exec xqf

ect ect ect…

you can also output it to a file like so
perl fvwm_menu.pl /usr/share/applications/ > fvwm_menu_file

Besure to open it and check the top 2 array/hash
Ive tried to document it for pub use lol … :laughing:

Again Im sorry if im posting this incorrectly


Sorry if I up the thread dated from Nov 07 8)

Here’s the right link ]http://1c3d.net/download.php?view.6[/url]

But, the script put some error on 2nd stdout so the script must me launch like that :

perl fvwm_menu.pl /usr/share/applications > menu.fvwm2rc 2>/dev/null

And the script create a menu.fvwm2rc that contain all the menus…

But, the script is not perfect because :
-Some application haven’t a *.desktop file
-Some application must be launch on a terminal

So, you can ameliorate the script with support of the line “Terminal” in .desktop files.

When “Terminal=true”, launch with "Exec exec $myterm -e myapplication.

For the first problem, I made a bash script who simply list the $PATH variable and compare with a db of application, but the script is slower than yours.


Sorry for my english :confused: