#!/bin/bash # /usr/bin/wm-gen-desktop-menu # Gilbert Ashley # this script can be used to generate a WindowMaker submenu # of installed programs which have a *.desktop file # the script expects a directory path as an argument. # In order to use this script, you need to first create a directory structure which # holds the menu categories as subdirectories with the *.desktop files in them. # To do that, first run the script /usr/bin/wm-update-desktop-menus # By default, this will create the menu subdirectories in ~/GNUstep/DesktopMenus # or you can use another directory by passing the directory path as an argument to the script # Then, you can add a line this to your WindowMaker WMRootMenu file: # ("Desktop Applications", OPEN_MENU, "|| /usr/bin/wm-gen-desktop-menu ~/GNUstep/DesktopMenus"), # Or you can use the WPrefs application to add a 'Generated Submenu' with this command: # /usr/bin/wm-gen-desktop-menu ~/GNUstep/DesktopMenus if [ $1 ] ; then DESKTOP_FILES_PATH=$1 else DESKTOP_FILES_PATH=~/GNUstep/DesktopMenus fi cd $DESKTOP_FILES_PATH echo \"Desktop Menu\" MENU for DIR in $(find * -type d) ; do echo \"$DIR\" MENU #for DSK in $(ls -1 $DIR ) ; do for DSK in $DIR/* ; do NAME=$(grep '^Name=' $DSK |cut -f2 -d=) COMMAND=$(grep '^Exec=' $DSK |cut -f2 -d=) COMMAND=${COMMAND/\%F/\"\$\@\"} COMMAND=${COMMAND/\%f/\"\$\1\"} COMMAND=${COMMAND/\%U/\"\$\@\"} COMMAND=${COMMAND/\%u/\"\$\1\"} #echo ${DSK/#*\/} $NAME echo " "\"$NAME\" EXEC "$COMMAND" DSK= NAME= COMMAND= done echo \"$DIR\" END DIR= done echo \"Desktop Menu\" END