Excuse my english, i'm from Argentina.
I've made a small script in bash to edit the lxmenu launchers, and i would like to share it with all of you.
Please, feel free to edit it or make corrections to it.
Here's the code:
Code: Select all
#!/bin/bash
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#################################################################################
#
# Contact: kameradklub@gmail.com
#
RUTA=(/usr/share/applications/*.desktop)
CONTADOR=0
IFS=":"
for i in "${RUTA[@]}"
do
ACTUAL=${RUTA[$CONTADOR]}
VERIFICAR=$(cat $ACTUAL | awk '/NoDisplay/ {print "1"}' )
if [ "$VERIFICAR" != "1" ]; then
printf "\n" >> $ACTUAL ; printf "NoDisplay=false" >> $ACTUAL
fi
let CONTADOR=$CONTADOR+1
done
CONTADOR=0
for b in "${RUTA[@]}"
do
ACTUAL=${RUTA[$CONTADOR]}
ARCHIVO=$(echo $ACTUAL | sed "s#/usr/share/applications/#""#")
INVALOR=$(cat $ACTUAL | awk -F"=" '/NoDisplay/ {print $2} ' )
NOMBRE1=$(cat $ACTUAL | awk -F"=" '/^Name=/ {print $2; exit}' | sed -e "s#[\ |:]#+#g")
NOMBRE="'$NOMBRE1' + "
if [ "$INVALOR" = "true" ]; then
echo "+ false +" >> lxcheckbox.txt
fi
if [ "$INVALOR" = "false" ]; then
echo "+ true +" >> lxcheckbox.txt
fi
sed -e '$s#$# '$NOMBRE# -i lxcheckbox.txt
sed -e '$s#$# '$ARCHIVO# -i lxcheckbox.txt
let CONTADOR=$CONTADOR+1
done
REMOVER=$(cat lxcheckbox.txt | tr -d '\ \n' | sed -e "s#+#\ #g")
echo $REMOVER > lxcheckbox.txt
CHECKBOX=$(cat lxcheckbox.txt)
echo $CHECKBOX > checkbox0.txt
OPCION=$(eval zenity --title=\"Edit LXMENU\" --width=300 --height=550 --list --checklist --multiple --column="Show" --column="Name" --column="File" $CHECKBOX --separator=":" )
OPCION1=($OPCION)
CONTADOR=0
CONTADOR1=0
ENCONTRADO=0
if [ "$OPCION1" != "" ]; then
for c in "${RUTA[@]}"
do
ACTUAL=${RUTA[$CONTADOR]}
ARCHIVO=$(echo $ACTUAL | sed "s#"/usr/share/applications/"#""#")
VALOR=$(cat $ACTUAL | awk -F"=" '/NoDisplay/ {print $2} ' )
NOMBRE=$(cat $ACTUAL | awk -F"=" '/^Name=/ {print $2; exit}' | sed -e "s#[\ |:]#\ #g")
for d in "${OPCION1[@]}"
do
OPCION2=${OPCION1[$CONTADOR1]}
if [ "$OPCION2" = "$NOMBRE" ]; then
ENCONTRADO=1
fi
let CONTADOR1=$CONTADOR1+1
done
if [ "$ENCONTRADO" = "1" -a "$VALOR" = "true" ]; then
sed -e 's/NoDisplay=true/NoDisplay=false/g' -i "$ACTUAL"
fi
if [ "$ENCONTRADO" = "0" -a "$VALOR" = "false" ]; then
sed -e 's/NoDisplay=false.*/NoDisplay=true/g' -i "$ACTUAL"
fi
ENCONTRADO=0
CONTADOR1=0
let CONTADOR=$CONTADOR+1
done
fi
rm lxcheckbox.txt
Enjoy!