How To: LXmenu Editor

Please post all general support questions for LXDE here.
Geert
Posts: 3
Joined: Mon Jun 06, 2011 3:56 am

How To: LXmenu Editor

Post by Geert »

Hello everyone,

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! :)
Last edited by Geert on Tue Jun 07, 2011 7:29 pm, edited 4 times in total.
seagradece
Posts: 1
Joined: Tue Jun 07, 2011 5:33 am

Re: LXmenu Editor

Post by seagradece »

Awesome!

I've been using it to remove many unwanted icons from the menu that appear after software upgrades (such as libreoffice). It works great, it is super fast and easy.

Thanks!
mow_
Posts: 1
Joined: Mon Jul 11, 2011 7:04 am

Re: LXmenu Editor

Post by mow_ »

ı m sorry.ı m new.what exactly do ı have to do to run this codes?
ueltume
Posts: 3
Joined: Sat Jul 09, 2011 9:43 pm

Re: LXmenu Editor

Post by ueltume »

mow_ wrote:ı m sorry.ı m new.what exactly do ı have to do to run this codes?
Yeah, me too. I'm a beginner when it comes to writing and executing code.
Motheroard: G41M-ES2L w/ 2.60 Ghz 2-core proc., 2 GB RAM, & 1 GB Vid RAM
Debian 6 STABLE w/: slim lxde-core libdvdnav4&read4 gstreamerbad&ugly reportbug-ng chromium gecko-mediaplayer p7zip transmission epdfview openoffice bleachbit claws-mail
Geert
Posts: 3
Joined: Mon Jun 06, 2011 3:56 am

Re: LXmenu Editor

Post by Geert »

Steps to run the code:

1º Create a text file called "lxmenu-editor.sh" and copy the code into it.
2º Give execute permission to it.
3º Execute it with this command: sh lxmenu-editor

If you see something like wrong names in the menu don't use it, just make click on "Cancel".
It's not a perfect script. It depends on wich ".desktop" files you have.
amjjawad
Posts: 304
Joined: Mon Aug 29, 2011 1:51 am
Contact:

Re: How To: LXmenu Editor

Post by amjjawad »

I have edited the subject to make it easier for everyone to search for it :)
Feel Free to contact me: http://amjjawad.net
vishcompany
Posts: 1
Joined: Tue Sep 13, 2011 10:26 pm

Re: How To: LXmenu Editor

Post by vishcompany »

Thanks a lot, Geert. Very useful script!
Geert
Posts: 3
Joined: Mon Jun 06, 2011 3:56 am

Re: How To: LXmenu Editor

Post by Geert »

amjjawad wrote:I have edited the subject to make it easier for everyone to search for it :)
Thanks!
vishcompany wrote:Thanks a lot, Geert. Very useful script!
Glad to know it :)
amjjawad
Posts: 304
Joined: Mon Aug 29, 2011 1:51 am
Contact:

Re: How To: LXmenu Editor

Post by amjjawad »

Geert wrote:
amjjawad wrote:I have edited the subject to make it easier for everyone to search for it :)
Thanks!
Any time :)
Feel Free to contact me: http://amjjawad.net
amjjawad
Posts: 304
Joined: Mon Aug 29, 2011 1:51 am
Contact:

Re: LXmenu Editor

Post by amjjawad »

Geert wrote:Steps to run the code:

1º Create a text file called "lxmenu-editor.sh" and copy the code into it.
2º Give execute permission to it.
3º Execute it with this command: sh lxmenu-editor

If you see something like wrong names in the menu don't use it, just make click on "Cancel".
It's not a perfect script. It depends on wich ".desktop" files you have.
Hi,

I tried that but nothing happened when I try to run it. Lubuntu 11.04 here.

Code: Select all

sh: Can't open lxmenu-editor
Feel Free to contact me: http://amjjawad.net
Locked