Hi, stu91!
The following is meant as a constructive critcicism -- to improve things.
It's already great that we have your menu generator. As well, I am not a programmer, mostly a "configuration guy", so I probably missed or misunderstood a few things in your script or your explanations -- for which I ask your forgiveness. That said...
I finally got your menu-creator to work, but not as a "dynamic" menu.
(Please see attached.)
It took me a little while to discover that this was a perl script.
And it didn't work as indicated, dynamically.
To create the menu, I had to issue, in console, the command
and then it clobbered the existing menu.
So the ending of the original menu file was lost. Now this last part is important because that's where the "goto" and "pekwm" parts of the menu proper are located, and also below that, you have the long part that controls the behaviour of the program windows (when you right-click on the program border).
Since I am not a perl programmer, I had to reconstruct the menu manually by
1) adding an additional "Submenu" command below the "run" command
2) inserting the programs part of your generated menu, and then
3) adding the bottom of the original menu.
Furthermore, here are a few comments about lines 13 - 14. There are other *.desktop files at
/usr/local/share/applications
and at
/root/.local/share/applications
(these being the applications controled by wine)
So the created pekwm menu may not be complete.
Also, I could not get the script to generate the menu a second time.
Again, I am posting this with a view to improve things, and in a spirit of collaboration. Hopefully, you will know how to proccess these remarks in order to make your generator script even better.
Because we definitely need one for the wonderful window manager that is pekwm!
Best regards.