djmattyg007

LXMenu Editor

May 19th, 2013
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.01 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # This is taken from the following thread:
  4. # http://forum.lxde.org/viewtopic.php?f=8&t=31189&p=37074
  5.  
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. #    it under the terms of the GNU General Public License as published by
  9. #    the Free Software Foundation, either version 3 of the License, or
  10. #   (at your option) any later version.
  11. #
  12. #    This program is distributed in the hope that it will be useful,
  13. #    but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. #    GNU General Public License for more details.
  16. #
  17. #    You should have received a copy of the GNU General Public License
  18. #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. #################################################################################
  21. #
  22. #
  23.  
  24. RUTA=(/usr/share/applications/*.desktop)
  25. CONTADOR=0
  26. IFS=":"
  27.  
  28. for i in "${RUTA[@]}"
  29. do
  30.     ACTUAL=${RUTA[$CONTADOR]}
  31.     VERIFICAR=$(cat $ACTUAL | awk '/NoDisplay/ {print "1"}' )
  32.     if [ "$VERIFICAR" != "1" ]; then
  33.         printf "\n" >> $ACTUAL ; printf "NoDisplay=false" >> $ACTUAL
  34.     fi
  35.     let CONTADOR=$CONTADOR+1
  36. done
  37.  
  38. CONTADOR=0
  39.  
  40. for b in "${RUTA[@]}"
  41. do
  42.     ACTUAL=${RUTA[$CONTADOR]}
  43.     ARCHIVO=$(echo $ACTUAL | sed "s#/usr/share/applications/#""#")
  44.     INVALOR=$(cat $ACTUAL | awk -F"=" '/NoDisplay/ {print $2} ' )
  45.     NOMBRE1=$(cat $ACTUAL | awk -F"=" '/^Name=/ {print $2; exit}' | sed -e "s#[\ |:]#+#g")
  46.     NOMBRE="'$NOMBRE1' + "
  47.     if [ "$INVALOR" = "true" ]; then
  48.         echo "+ false +"  >> lxcheckbox.txt
  49.     fi
  50.     if [ "$INVALOR" = "false" ]; then
  51.         echo "+ true +"  >> lxcheckbox.txt
  52.     fi
  53.     sed -e '$s#$# '$NOMBRE# -i lxcheckbox.txt
  54.     sed -e '$s#$# '$ARCHIVO# -i lxcheckbox.txt
  55.     let CONTADOR=$CONTADOR+1
  56. done
  57. REMOVER=$(cat lxcheckbox.txt | tr -d '\ \n' | sed -e "s#+#\ #g")
  58. echo $REMOVER > lxcheckbox.txt
  59. CHECKBOX=$(cat lxcheckbox.txt)
  60.  
  61. echo $CHECKBOX > checkbox0.txt
  62.  
  63. OPCION=$(eval zenity --title=\"Edit LXMENU\" --width=300 --height=550 --list --checklist --multiple --column="Show" --column="Name" --column="File" $CHECKBOX --separator=":" )
  64.  
  65. OPCION1=($OPCION)
  66. CONTADOR=0
  67. CONTADOR1=0
  68. ENCONTRADO=0
  69.  
  70. if [ "$OPCION1" != "" ]; then
  71.     for c in "${RUTA[@]}"
  72.     do
  73.         ACTUAL=${RUTA[$CONTADOR]}
  74.         ARCHIVO=$(echo $ACTUAL | sed "s#"/usr/share/applications/"#""#")
  75.         VALOR=$(cat $ACTUAL | awk -F"=" '/NoDisplay/ {print $2} ' )
  76.         NOMBRE=$(cat $ACTUAL | awk -F"=" '/^Name=/ {print $2; exit}' | sed -e "s#[\ |:]#\ #g")
  77.    
  78.         for d in "${OPCION1[@]}"
  79.         do
  80.             OPCION2=${OPCION1[$CONTADOR1]}
  81.             if [ "$OPCION2" = "$NOMBRE" ]; then
  82.                 ENCONTRADO=1
  83.             fi
  84.             let CONTADOR1=$CONTADOR1+1
  85.         done
  86.      
  87.         if [ "$ENCONTRADO" = "1" -a "$VALOR" = "true" ]; then
  88.             sed -e 's/NoDisplay=true/NoDisplay=false/g' -i "$ACTUAL"
  89.         fi
  90.      
  91.         if [ "$ENCONTRADO" = "0" -a "$VALOR" = "false" ]; then
  92.             sed -e 's/NoDisplay=false.*/NoDisplay=true/g' -i "$ACTUAL"
  93.         fi
  94.  
  95.         ENCONTRADO=0
  96.         CONTADOR1=0
  97.         let CONTADOR=$CONTADOR+1
  98.     done
  99. fi
  100.  
  101. rm lxcheckbox.txt
Advertisement
Add Comment
Please, Sign In to add comment