From: <dom...@us...> - 2012-07-12 21:44:14
|
Revision: 122 http://fvwm-crystal.svn.sourceforge.net/fvwm-crystal/?rev=122&view=rev Author: dominique_libre Date: 2012-07-12 21:44:08 +0000 (Thu, 12 Jul 2012) Log Message: ----------- fvwm-crystal.generate-menu: added handling of parameters for use from the shell or from crystal Modified Paths: -------------- bin/fvwm-crystal.generate-menu fvwm/components/functions/Preferences-Menu Modified: bin/fvwm-crystal.generate-menu =================================================================== --- bin/fvwm-crystal.generate-menu 2012-07-12 19:50:51 UTC (rev 121) +++ bin/fvwm-crystal.generate-menu 2012-07-12 21:44:08 UTC (rev 122) @@ -16,22 +16,52 @@ # When running this script as user, the files will be generated in FVWM_USERDIR, # as root, in FVWM_SYSTEMDIR # +# Syntax from fvwm-crystak: +# fvwm-crystal.generate-menu $[FVWM_SYSTEMDIR] $[FVWM_USERDIR] +# # For a detailled view of the algorhythm, open generate_menu.png in your favorite # picture viewer. # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# Change the following variables if needed + +# Your real id +your_id="$(id -un)" + +# If run from a shell +if [ $# -lt 2 ]; then + echo "Running $0 from the shell" + # Where are the Fvwm-Crystal menu files: + FC_MENUBASEROOT="/usr/share/fvwm-crystal/fvwm/Applications" + FC_MENUBASEUSER="/.fvwm-crystal/Applications" + # Where are the Fvwm-Crystal icons files: + FC_ICONBASEROOT="/usr/share/fvwm-crystal/fvwm/icons/Default" + FC_ICONBASEUSER="/.fvwm-crystal/icons/Default" + # Test which user run the script. Ir root, install in FVWM-SYSTEMDIR, + # otherwise in FVWM_USERDIR. If ROOT, existing entry will be searched + # only in FVWM_SYSTEMDIR, otherwise in both FVWM_DIR. + if [[ "${your_id}" == root ]]; then + FC_MENUBASE="${FC_MENUBASEROOT}" + FC_ICONBASE="${FC_ICONBASEROOT}" + FC_MENUEXIST="${FC_MENUBASEROOT}" + FC_ICONEXIST="${FC_ICONBASEROOT}" + else + FC_MENUBASE="/home/${your_id}${FC_MENUBASEUSER}" + FC_ICONBASE="/home/${your_id}${FC_ICONBASEUSER}" + FC_MENUEXIST="${FC_MENUBASEROOT} /home/${your_id}${FC_MENUBASEUSER}" + FC_ICONEXIST="${FC_ICONBASEROOT} /home/${your_id}${FC_ICONBASEUSER}" + fi +else + FC_MENUBASEROOT="$1/Applications" + FC_ICONBASEROOT="$1/icons/Default" + FC_MENUBASE="$2/Applications" + FC_ICONBASE="$2/icons/Default" + FC_MENUEXIST="${FC_MENUBASEROOT} ${FC_MENUBASE}" + FC_ICONEXIST="${FC_ICONBASEROOT} ${FC_ICONBASE}" +fi + SIZES="22x22 32x32 48x48" + # -# Where are the Fvwm-Crystal menu files: -FC_MENUBASEROOT="/usr/share/fvwm-crystal/fvwm/Applications" -FC_MENUBASEUSER="/.fvwm-crystal/Applications" # -# Where are the Fvwm-Crystal icons files: -FC_ICONBASEROOT="/usr/share/fvwm-crystal/fvwm/icons/Default" -FC_ICONBASEUSER="/.fvwm-crystal/icons/Default" -SIZES="22x22 32x32 48x48" -# -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # Don't change anything past this line # # # # # # # # # # # # # # # # # # # # # # # # # # # @@ -39,12 +69,14 @@ # Type of .desktop files to search for DESKTYPE="Type=Application" -# Other variables -your_id="$(id -un)" - # Where are the preferences: -SYSPREFS="/usr/share/fvwm-crystal/fvwm/preferences" -USERPREFS="/home/$your_id/.fvwm-crystal/preferences" +if [ $# -lt 2 ]; then + SYSPREFS="/usr/share/fvwm-crystal/fvwm/preferences" + USERPREFS="/home/$your_id/.fvwm-crystal/preferences" +else + SYSPREFS="$1/preferences" + USERPREFS="$2/preferences" +fi loadpref() { # Copy default user prefs if they don't exist. @@ -59,46 +91,24 @@ # Load the icon files preference: loadpref IconDirs SYSTEM_ICONDIRS -echo "SYSTEM_ICONDIRS est $SYSTEM_ICONDIRS" # Load the desktop files preference: loadpref DesktopDirs DesktopDir # User dependent variables -# Test which user run the script. Ir root, install in FVWM-SYSTEMDIR, -# otherwise in FVWM_USERDIR. If ROOT, existing entry will be searched -# only in FVWM_SYSTEMDIR, otherwise in both FVWM_DIR. -if [[ "${your_id}" == root ]]; then - FC_MENUBASE="${FC_MENUBASEROOT}" - FC_ICONBASE="${FC_ICONBASEROOT}" - FC_MENUEXIST="${FC_MENUBASEROOT}" - FC_ICONEXIST="${FC_ICONBASEROOT}" - else - FC_MENUBASE="/home/${your_id}${FC_MENUBASEUSER}" - FC_ICONBASE="/home/${your_id}${FC_ICONBASEUSER}" - FC_MENUEXIST="${FC_MENUBASEROOT} /home/${your_id}${FC_MENUBASEUSER}" - FC_ICONEXIST="${FC_ICONBASEROOT} /home/${your_id}${FC_ICONBASEUSER}" -fi -echo "You are running generate-fvwm-crystal-menu as user ${your_id}." +echo "You are running $0 as user ${your_id}." +echo " " echo "FVWM-Crystal menu entries will be installed in" -echo "$FC_MENUBASE and the icons in $FC_ICONBASE" +echo "$FC_MENUBASE and the icons in $FC_ICONBASE." +echo " " echo "The program will search for existing menu entries in $FC_MENUEXIST and for existing" -echo " icons in $FC_ICONEXIST" -echo "" -echo "Are you sure that you want to process? yes/no" +echo " icons in $FC_ICONEXIST." +echo "It will look for desktop file into $DesktopDir and for original icons into $SYSTEM_ICONDIRS" +echo " " +echo "Installing the menu entrie in $FC_MENUBASE and the icons in $FC_ICONBASE" + read PROCESS -if [[ "${PROCESS}" == yes ]]; then - echo "Installing the menu entries in $FC_MENUBASE and the icons in $FC_ICONBASE" - else - if [[ "${PROCESS}" == no ]]; then - echo "abort" - else - echo "Please answer yes or no !" - fi - exit -fi - # / FIXME (this part work, see searchkeystrings()) # Locale test #echo "" @@ -118,14 +128,18 @@ # END FIXME / # Parameter test -if [[ $1 == "" ]]; then - echo "- Searching for all the desktop files in $DesktopDir" - echo "" - echo "This will go fast..." +if [ $# -lt 2 ]; then + if [[ $1 == "" ]]; then + echo "- Searching for all the desktop files in $DesktopDir" + echo "" + echo "This will go fast..." + searchdesktop="searchallappdesktop" + else + echo "- Searching for $1.desktop in $DesktopDir" + searchdesktop="searchoneappdesktop" + fi +else searchdesktop="searchallappdesktop" - else - echo "- Searching for $1.desktop in $DesktopDir" - searchdesktop="searchoneappdesktop" fi # Remove the temp files if the user press Ctrl-C @@ -1006,4 +1020,6 @@ echo "" echo "You will find the list of the desktop files with non valid Main Category in non_valid_cat.log" -FvwmCommand 'Module FvwmForm Menu-Restart-Dialog' +if [ $# -ge 2 ]; then + FvwmCommand 'Module FvwmForm Menu-Restart-Dialog' +fi Modified: fvwm/components/functions/Preferences-Menu =================================================================== --- fvwm/components/functions/Preferences-Menu 2012-07-12 19:50:51 UTC (rev 121) +++ fvwm/components/functions/Preferences-Menu 2012-07-12 21:44:08 UTC (rev 122) @@ -447,7 +447,7 @@ # DestroyFunc GenerateApplicationMenu AddToFunc GenerateApplicationMenu -+ I A fvwm-crystal.generate-menu ++ I A "fvwm-crystal.generate-menu $[FVWM_SYSTEMDIR] $[FVWM_USERDIR]" All (Menu-Restart-Dialog) Close DestroyModuleConfig Menu-Restart-Dialog: * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |