Kamerad

LXMENU EDITOR

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