Home > GNOME > Removing KDE icons in gnome / remove gnome icons in KDE

Removing KDE icons in gnome / remove gnome icons in KDE

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.

menu-cleaner.sh v0.1

Categories: GNOME Tags: ,
  1. July 18th, 2007 at 19:25 | #1

    Rock on! I have been asking this everywhere with no reply. Awesome!

  2. July 18th, 2007 at 19:40 | #2

    Btw, is this a permanent fix or will I need to run this everytime I install new applications?

  3. July 18th, 2007 at 19:44 | #3

    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.

  4. Lucian
    July 19th, 2007 at 03:56 | #4

    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?

  5. tidiman07
    July 25th, 2007 at 08:30 | #5

    does it work with xfce4 too? Xubuntu-desktop? I’m gonna try it.

  6. July 25th, 2007 at 10:07 | #6

    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

  7. July 26th, 2007 at 14:54 | #7

    I had written about this over a year ago. It is good to see it get around, though.

  8. July 26th, 2007 at 18:27 | #8

    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.

  9. Brad
    October 4th, 2007 at 21:51 | #9

    404 on the script..

  10. October 5th, 2007 at 07:42 | #10

    Brad – thank you for pointing that out. I have updated the link. It should work now.

  11. Chris
    October 23rd, 2007 at 02:00 | #11

    Will this work on Fedora as well? I have both GNOME and KDE on Fedora 7 and I was looking for such a fix.

  12. October 23rd, 2007 at 06:37 | #12

    Chris – as far as I know it should work in KDE, although I have not directly tested it.

  13. Chris
    October 23rd, 2007 at 10:07 | #13

    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.

  14. Chris
    October 25th, 2007 at 01:36 | #14

    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.

  15. Annoym
    November 11th, 2007 at 18:30 | #15

    I happen to have the same problem that Chris has.

  16. November 24th, 2007 at 08:34 | #16

    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: >”“”< )

  17. Jlar
    November 27th, 2007 at 15:11 | #17

    Just a little fix. :-P

    If you’re running the commands manually, the first one should be:

    “mkdir -p ~/.menu-backup/{gnome,kde}”

  18. December 27th, 2007 at 15:34 | #18

    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.

  19. Lewis
    February 20th, 2008 at 09:44 | #19

    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)

  20. michele
    July 10th, 2008 at 08:48 | #20

    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?

  21. locazoreloco
    July 26th, 2008 at 06:00 | #21

    THIS DOESN’T WORK IN HARDY, HELP!!! I TRIED WITH THE ORIGINAL POST AND THE CHANGES THAT ZLATAN SUGGEST BUT NOTHING HAPPENED!

  22. jersoncito
    August 2nd, 2008 at 14:52 | #22

    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

  23. eric gunstone
    October 10th, 2008 at 22:37 | #23

    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?

  24. November 16th, 2008 at 18:38 | #24

    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

  25. Henry
    January 9th, 2009 at 11:31 | #25

    The first command is missing a virgule.

    mkdir -p ~/.menu-backup{gnome,kde}

    should be

    mkdir -p ~/.menu-backup/{gnome,kde}

  26. oiad
    February 11th, 2009 at 17:32 | #26

    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.

  27. mrHappyPants
    April 15th, 2009 at 11:42 | #27

    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 christer.edwards@ubuntu.com
    #
    # 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

  28. mrHappyPants
    April 15th, 2009 at 12:27 | #28

    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

  29. mrHappyPants
    April 15th, 2009 at 12:36 | #29

    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 christer.edwards@ubuntu.com
    #
    # 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

  30. Topheth
    July 6th, 2010 at 17:34 | #30

    Can this be restored if the backups are lost?

  31. Luis Alford
    July 23rd, 2010 at 20:58 | #31

    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

  32. whiteboo
    March 30th, 2011 at 04:06 | #32

    Could anyone tell me how to restore my files with the backup?

  1. July 19th, 2007 at 15:44 | #1
  2. July 19th, 2007 at 16:15 | #2
  3. July 19th, 2007 at 18:49 | #3
  4. July 19th, 2007 at 23:12 | #4
  5. July 24th, 2007 at 01:50 | #5
  6. July 31st, 2007 at 12:33 | #6
  7. October 23rd, 2007 at 12:36 | #7
  8. October 29th, 2007 at 14:43 | #8