Mod and hack the GNome main menu with automated scripts to create a menu of the directory.

Problem:
I had a directory with very good collection of my scripts and very organized in folders. The structure is something like this, first I have the broad classification of the category. Then I have the name of the tool/script as the name of the directory. All these are perl/python or shell scripts and luckily labelled so with the extension. I want to add these to the GNome main (Applications) menu.
Solution:
Lets take it stepwise:
1) Add new menu tools to the Applications menu. Go to /etc/xdg/menus
Open the file applications.menu and add the following before <DefaultMergeDirs/>

2) Now go to directory \”/etc/xdg/menus/applications-merged\” and create a new file called \”test-categories.menu\” and put the following in the file:

<Menu>
<Name>Applications</Name>

<Menu>
<Name>Pentest</Name>
<Menu>
<Name>database</Name> <!– name of the directory in menu –>
<Directory>pentest-database.directory</Directory>
<Include>
<And>
<Category>database</Category> <!– This is the category that you need to add in the desktop file.–>
</And>
</Include>
</Menu>

</Menu>
</Menu>

You can include as many directory as you want.

3) Now the fun part of creating the desktop files that link to the perl/python or the shell scripts and actually populate the menu. Note: Until the menu contains any item, the menu will not appear. Okay, go to directory \”/usr/share/applications/test\”. Create a shell script with the following and run it in the directory containing your scripts, and then \”mv *.desktop /usr/share/applications/test\”: