This tutorial is for those people that like to run gnome and KDE side by side. This will allow you to only show the native apps in the menus within each desktop environment instead of showing everything.
update: I wrote a script to automate this process. If you’d like to use that instead it is available below.
You can run the following commands to make gnome menu backups and KDE menu backups prior to making the changes, if you want to be safe.
mkdir -p ~/.menu-backup{gnome,kde}
cp /usr/share/applications/* ~/.menu-backup/gnome
cp /usr/share/applications/kde/* ~/.menu-backup/kde
To update the menu listings then run (one continued line):
sudo -i
cd /usr/share/applications/ ; for i in *; do echo “ShowOnlyIn=GNOME” >> $i; done ; cd /usr/share/applications/kde/ ; for i in *; do echo “ShowOnlyIn=KDE” >> $i; done ; exit
The changes should take place immediately and you should now only see the native apps in each menu. Enjoy.
If everything seems to work the way you like you can delete the backup directories with the following commands:
rm -r ~/.menu-backup-gnome
rm -r ~/.menu-backup-kde
I suppose I could write a small shell script to do the work for you.. would anyone prefer that? I got bored and wrote it.
Rock on! I have been asking this everywhere with no reply. Awesome!
Btw, is this a permanent fix or will I need to run this everytime I install new applications?
Lucian – It is not a permanent fix, and I’ll need to update a bit of the code to allow it to cleanly be re-run after new apps are installed.. I’ll try to set some time for that.
Thanks for the reply. What will I need to do manually to run this script again?
NOTE: I have noticed some changes in the script since last night. Is it now possible to re-run the script or was something else fixed?
Pingback: Linux Tip: Hide KDE apps in Gnome menus : Teknicks Blog
Pingback: Techzi » Blog Archive » Linux Tip: Hide KDE apps in Gnome menus
Pingback: Linux Tip: Hide KDE apps in Gnome menus at SoftSaurus
Pingback: Enlever les icones KDE du menu Gnome et vice-versa - [ChaChat’s Homepage]
Pingback: Technology » Blog Archive » Linux Tip: Hide KDE apps in Gnome menus
does it work with xfce4 too? Xubuntu-desktop? I’m gonna try it.
tidiman07 – it does not work with XFCE unless you run it *before* you install XFCE. The problem is the desktop menu icons are located in the same place for XFCE and gnome, whereas KDE places them in a separate directory.
If I get time to keep working on this I could put something together, but currently it’s gnome and KDE specific
I had written about this over a year ago. It is good to see it get around, though.
Hi, I am also looking to get this to work on Xfce. I would like to install Xubuntu so I can work with Documentation easier but dislike all the additional icons that clutter up the K menu. Have you done anything with editing the script? Also, a not so elegant solution would be to have the script run in a cron job so that it eventually cleans up the menus for KDE & GNOME.
Pingback: Hide KDE apps in Gnome menus at SoftSaurus
404 on the script..
Brad – thank you for pointing that out. I have updated the link. It should work now.
Will this work on Fedora as well? I have both GNOME and KDE on Fedora 7 and I was looking for such a fix.
Chris – as far as I know it should work in KDE, although I have not directly tested it.
So far the terminal commands don’t work exactly as they shoud, some of the backing up had to be done manually. Right now I’m out but I’ll try the rest of it when I get home.
Pingback: rapidoda » Blog Archive » Comment on Removing KDE icons in gnome / remove gnome icons in KDE …
Ok, so I finally got to run it in the terminal and it returned the following which I don’t know it it is normal or not:
-bash: kde: Is a directory
-bash: kde4: Is a directory
-bash: screensavers: Is a directory
logout
And the KDE menus are not hidden nor are the GNOME ones in KDE.
Pingback: Hide KDE apps in Gnome menus [Linux Tip] at SoftSaurus
I happen to have the same problem that Chris has.
The problem in Ubuntu 7.10 is in “ShowOnlyIn=GNOME” and “ShowOnlyIn=KDE”
That parts should be written as:
“OnlyShowIn=GNOME” and “OnlyShowIn=KDE” (note: >”“”< )
Just a little fix. 😛
If you’re running the commands manually, the first one should be:
“mkdir -p ~/.menu-backup/{gnome,kde}”
For those looking for the menu-cleaner.sh script: http://www.programming-designs.com/linux/menu-cleaner.sh
This tutorial didn’t help in Gutsy so I had to use the script instead.
Do I just copy the entire code above as one line, and do I need both GNOME and KDE already installed (one I’ve seen said to run part of the code first, then install KDE and then run the second part of the code)
There is a way to go back? i loose my backup and i want the kde apps back on my gnome menu. It’s possible?
THIS DOESN’T WORK IN HARDY, HELP!!! I TRIED WITH THE ORIGINAL POST AND THE CHANGES THAT ZLATAN SUGGEST BUT NOTHING HAPPENED!
The script that Daniel said
http://www.programming-designs.com/linux/menu-cleaner.sh
worked with KDE4 for me. but I had to change the script with a text editor (kde to kde4)
Thanks
I ran just installed kubuntu-desktop in ubuntu 8.04 Gmone and didn’t like all the mix of menu items, I ran menu-cleaner.sh and it seems to have cleaned up most of rhe Gnome menus but now i don’t have hardly any icons in the KDE menu’s… how do I restore them?
I’m running 8.10 Intrepid Ibex. I have Ubuntu – and will be installing Kubuntu.
Do I have to modify the script in any way?
Thanks,
Martin
The first command is missing a virgule.
mkdir -p ~/.menu-backup{gnome,kde}
should be
mkdir -p ~/.menu-backup/{gnome,kde}
for intrepid you should download the above .sh file and then run it in the terminal once
./menu-cleaner.sh
then open it in a text editor and change both of the two
/usr/share/applications/kde
lines to:
/usr/share/applications/kde4
This way it will get all of the apps for you.
or you can simply copy the block of code and chance the kde to kde4. ie change it to:
#!/bin/bash
###########
# menu-cleaner.sh will consolidate your desktop environment menus, meaning
# that your gnome applications will only show in gnome and your KDE
# applications will only show in KDE. This came from my biggest pet peeve
# of seeing *all* of the applications in both desktop environments.
#
# BUGS: I have no idea, it's a really simple app. Report them if you find them
# at [email protected]
#
# LICENSE: menu-cleaner.sh is released under the Public Domain.
if [[ $EUID -ne 0 ]]
then
echo "##############################################"
echo "# You must be root / sudo to run this script #"
echo "##############################################"
exit 1
else
echo
echo "Creating backup folder"
echo
mkdir -p ~/.menu-backup/{gnome,kde} &>/dev/null
cp /usr/share/applications/* ~/.menu-backup/gnome/ &>/dev/null
cp /usr/share/applications/kde/* ~/.menu-backup/kde/ &>/dev/null
if [[ $? -ne 0 ]]
then
echo "backup failed, exiting menu-cleaner"
exit 1
fi
echo "Updating gnome menu entries"
echo
cd /usr/share/applications/
for i in *; do echo "OnlyShowIn=GNOME" >> $i; done &>/dev/null
if [[ $? -ne 0 ]]
then
echo "gnome menu cleaner failed, exiting."
exit 1
fi
echo "Updating KDE menu entries"
echo
cd /usr/share/applications/kde/
for i in *; do echo "OnlyShowIn=KDE" >> $i; done &>/dev/null
if [[ $? -ne 0 ]]
then
echo "KDE menu cleaner failed, exiting"
exit 1
fi
echo "Updating KDE4 menu entries"
echo
cd /usr/share/applications/kde4/
for i in *; do echo "OnlyShowIn=KDE" >> $i; done &>/dev/null
if [[ $? -ne 0 ]]
then
echo "KDE4 menu cleaner failed, exiting"
exit 1
fi
echo "menu-cleaner successful. Enjoy"
echo
fi
also, i made a copy of the contents of /usr/share/applications/ before and after installing XFCE and compared the two files. The extra applications were obviously installed by XFCE and thus would preferably only appear in XFCE, so thats a messy way of altering the script for those who are interested. The following is a list of my differences, may be different for you guys though
exo-preferred-applications.desktop
fedora-mousepad.desktop
fedora-Thunar-bulk-rename.desktop
fedora-Thunar.desktop
fedora-Thunar-folder-handler.desktop
fedora-thunar-volman-settings.desktop
fedora-xarchiver.desktop
Terminal.desktop
xfce4-appfinder.desktop
xfce4-autostart-editor.desktop
xfce4-mixer.desktop
xfce4-panel-manager.desktop
xfce-backdrop-settings.desktop
xfce-display-settings.desktop
xfce-keyboard-settings.desktop
xfce-menueditor.desktop
xfce-mixer-settings.desktop
xfce-mouse-settings.desktop
xfce-session-settings.desktop
xfce-settings-manager.desktop
xfce-splash-settings.desktop
xfce-ui-settings.desktop
xfce-wm-settings.desktop
xfce-wmtweaks-settings.desktop
xfce-workspaces-settings.desktop
okay so my posts are probably starting to get annoying, but for anyone who is interested, my updated /bin/menu-cleaner is:
#!/bin/bash
###########
# menu-cleaner.sh will consolidate your desktop environment menus, meaning
# that your gnome applications will only show in gnome and your KDE
# applications will only show in KDE. This came from my biggest pet peeve
# of seeing *all* of the applications in both desktop environments.
#
# BUGS: I have no idea, it's a really simple app. Report them if you find them
# at [email protected]
#
# LICENSE: menu-cleaner.sh is released under the Public Domain.
if [[ $EUID -ne 0 ]]
then
echo "##############################################"
echo "# You must be root / sudo to run this script #"
echo "##############################################"
exit 1
else
echo
echo "Creating backup folder"
echo
mkdir -p ~/.menu-backup/{gnome,kde} &>/dev/null
cp /usr/share/applications/* ~/.menu-backup/gnome/ &>/dev/null
cp /usr/share/applications/kde/* ~/.menu-backup/kde/ &>/dev/null
if [[ $? -ne 0 ]]
then
echo "backup failed, exiting menu-cleaner"
exit 1
fi
echo "Updating gnome menu entries"
echo
cd /usr/share/applications/
for i in *; do echo "OnlyShowIn=GNOME" >> $i; done &>/dev/null
if [[ $? -ne 0 ]]
then
echo "gnome menu cleaner failed, exiting."
exit 1
fi
echo "Updating KDE menu entries"
echo
cd /usr/share/applications/kde/
for i in *; do echo "OnlyShowIn=KDE" >> $i; done &>/dev/null
if [[ $? -ne 0 ]]
then
echo "KDE menu cleaner failed, exiting"
exit 1
fi
echo "Updating KDE4 menu entries"
echo
cd /usr/share/applications/kde4/
for i in *; do echo "OnlyShowIn=KDE" >> $i; done &>/dev/null
if [[ $? -ne 0 ]]
then
echo "KDE4 menu cleaner failed, exiting"
exit 1
fi
echo "Updating XFCE menu entries"
echo
cd /usr/share/applications/
for i in exo-preferred-applications.desktop; do echo "OnlyShowIn=XFCE" >> $i; done &>/dev/null
for i in fedora-mousepad.desktop; do echo "OnlyShowIn=XFCE" >> $i; done &>/dev/null
for i in fedora-*hunar*; do echo "OnlyShowIn=XFCE" >> $i; done &>/dev/null
for i in fedora-xarchiver.desktop; do echo "OnlyShowIn=XFCE" >> $i; done &>/dev/null
for i in Terminal.desktop; do echo "OnlyShowIn=XFCE" >> $i; done &>/dev/null
for i in xfce*; do echo "OnlyShowIn=XFCE" >> $i; done &>/dev/null
if [[ $? -ne 0 ]]
then
echo "XFCE menu cleaner failed, exiting"
exit 1
fi
echo "menu-cleaner successful. Enjoy"
echo
fi
Can this be restored if the backups are lost?
hi,
I run this script and now all I see when I log in is a purple screen ..please help I have the latest ubuntu version
thanks I really need it
Could anyone tell me how to restore my files with the backup?