Freelancer's Playground! Learn Programming, The Freelancer's Way

19Aug/092

Show/Hide Desktop Icons in XFCE

If you follow this blog, you should know that I had already posted an entry about this topic, but for gnome desktop. In XFCE, you will go on different route. The visual ways will go to this path: Applications » Settings » Desktop. In Desktop preferences, go to 'Icons' tab. There, you just need to set 'Icon type' to 'None' and set it back to 'File/Launcher Icons' to bring them back.

But, if you are like me, who did show/hide desktop icons many times a day, you'll feel that it's a bit tedious. Furthermore, if you came from windows world, you'll missed it's show/hide desktop icons that is embedded in right click menu on desktop. But, don't worry. I've came up with solution;). All you have to do is open up text editor and copy-paste this code:

#!/bin/bash

current_status=$( xfconf-query -c xfce4-desktop -v -lp '/desktop-icons/style' |cut -d"&" -f2|cut -d" " -f3 )
echo "Current Status: &" $current_status;

if [ $current_status -eq 2 ]
then
echo "Disabling desktop icon..."
xfconf-query -c xfce4-desktop -np '/desktop-icons/style' -t 'int' -s '0';
else
echo "Activating desktop icon..."
xfconf-query -c xfce4-desktop -np '/desktop-icons/style' -t 'int' -s '2';
fi;

Then, save it in your home directory and call it switch_xfce_desktop_icon. Preferably under bin directory inside your home dir (

/home/username/bin/switch_xfce_desktop_icon

). Now that you have the script, the next step is to make the script executable. In linux, there are two method on how to make particular script executable. First, by executing command using terminal window. The other one is using file manager. In this post, I'll tell you using the GUI way[1]. To do this, open up the file manager from Places » username, and then navigate to where you save the file. After you've located it, right click on it and choose Properties. Open up Permissions tab and check on Allow this file to to run as a program. That's it, now you have an executable script.

Next step, you will need a shortcut / button for easy access. To do this, you have to right click on the bottom panel (just right after show/hide desktop window icon) and click on Add new items. On Add new items window, add Launcher.

On Launcher window, fill this as information:

Name: Show/Hide Desktop Icons
Description: Show or Hide Desktop Icons
Icon: Click on the button and choose which icon you want
Command: /home/username/bin/switch_xfce_desktop_icon
Working Directory: /home/username/bin/
Run in terminal: uncheck
Use startup notification: uncheck

Then, save it by clicking on OK button. That's it, now you have show/hide desktop icon button on your XFCE!

[1]If you insist on using the terminal window, launch the terminal by navigating to Applications » Accessories » Terminal. On your terminal window, write this command:

chmod u+x /home/username/bin/switch_xfce_desktop_icon

and hit ENTER. Then, close your terminal window.

Filed under: Tutorial Leave a comment
  • James
    #!/bin/bash

    current_status=$( xfconf-query -c xfce4-desktop -v -lp '/desktop-icons/style' |cut -d"&" -f2|cut -d" " -f3 )
    echo "Current Status: &" $current_status;

    if [ $current_status -eq 2 ]
    then
    echo "Disabling desktop icon..."
    xfconf-query -c xfce4-desktop -np '/desktop-icons/style' -t 'int' -s '0';
    else
    echo "Activating desktop icon..."
    xfconf-query -c xfce4-desktop -np '/desktop-icons/style' -t 'int' -s '2';
    fi;
  • ahaha, good one!
    I'll fix my post.

    Thanks.
blog comments powered by Disqus