2

I'm looking for a way to hide the entire desktop + icons and then launching a single app. It's for productivity usage, if that makes any sense. How can I programmatically make my desktop blank (i.e. remove the icons and make it black) from the command line? I'd also like to be able to restore it afterwards.

Multiple solutions are OK, Ubuntu, GNOME, etc. but it would be ideal if there was one way to do this for all desktops.

  • Why do you not use a blank screen-saver? – Nils Aug 5 '13 at 13:33
  • @Nils - Yeah I'm not trying to blank my screen like that in a screensaver situation, this is for use in a productivity situation where I want all the background noise of a desktop gone and just a single window displayed. – slm Aug 5 '13 at 15:37
8

Removing the icons is the easy part. Just move all of the files in ~/Desktop to a temporary location:

mkdir ~/backup_icons
mv ~/Desktop/* ~/backup_icons
mv ~/backup_icons/* ~/Desktop # restore

Changing the background is going to be specific to your DE. I found this Ubuntu SE answer which shows that you can use the gsettings command in Gnome and Unity.

gsettings set org.gnome.desktop.background picture-uri file:///home/serrano/Pictures/blank_image.jpg
  • I think that even the removal of icons will be DE-specific as you have things like Home folder ucon an Trash icon. – Joseph R. Aug 5 '13 at 16:24
  • 1
    @JosephR. - I have not used a DE which displayed desktop icons other than was in ~/Desktop. I am pretty sure the ~/Desktop dir is somewhere in the freedesktop.org specs. – jordanm Aug 5 '13 at 17:01
  • That's weird. In GNOME, for example, the Home Folder icon and the Trash icon and similar stuff can only be removed from the desktop by editing appropriate keys in the gconf database. – Joseph R. Aug 5 '13 at 17:07
  • 1
    Also, you will probably lose icon positions in most desktops. – orion Jan 20 '15 at 11:31
0

I'm on Ubuntu 11.04, with Gnome 2, and I managed to cook up a bash script, which uses gconftool-2 to temporarily set corresponding gconf keys to hide icons and change desktop background; and then the script blocks in the terminal (using an endless loop of read) - until Ctrl-C is pressed; at which time the original settings are restored.

I've uploaded the script here: bckg-desk-tmpchange.sh ; and the guts of it are here:

replace_image="/usr/share/backgrounds/space-02.jpg"

# Ubuntu 11.04, Gnome 2 - get initial settings:
orig_pic_fn=$(gconftool-2 --get  "/desktop/gnome/background/picture_filename")
orig_show_desk=$(gconftool-2 --get  "/apps/nautilus/preferences/show_desktop")
orig_draw_bckg=$(gconftool-2 --get  "/desktop/gnome/background/draw_background")

restore_originals() {
  echo
  echo "  Restoring original show_desktop: ${orig_show_desk} and original picture_filename: ${orig_pic_fn}"
  gconftool-2 --set "/desktop/gnome/background/picture_filename" --type string ${orig_pic_fn}
  sleep 1
  gconftool-2 --set "/apps/nautilus/preferences/show_desktop" --type bool ${orig_show_desk}
  gconftool-2 --set "/desktop/gnome/background/draw_background" --type bool ${orig_draw_bckg}
}
trap "restore_originals; echo; exit 0" INT

# -------------

echo "Original show_desktop (icons): ${orig_show_desk}"
echo "Original (desktop) picture_filename: ${orig_pic_fn}"

echo
echo "Setting temporary desktop settings: no icons, custom image ${replace_image}"
echo

gconftool-2 --set "/desktop/gnome/background/picture_filename" --type string ${replace_image}
sleep 1
gconftool-2 --set "/apps/nautilus/preferences/show_desktop" --type bool false

while [ 1 ]; do
  read -p "Blocking with read, and waiting for a Ctrl-C interrupt... " dontcare
done
0

Desktop is just another X application that displays whatever it wants - it's a matter of history and tradition that mostly people just want icons there, although widgets have become quite common in the last 5 years. Unlike the mainstream desktop environments, more lightweight standalone window managers don't start a desktop application on their own, and mostly just set the color/image of the root window (the window that contains all other windows). Ideally you would want to stop the whatever application manages the desktop - then you are left with just a blank root window, and it doesn't mess up all your icon settings (which will probably happen if you just move the shortcuts somewhere else).

The desktop application may be plasma (KDE), nautilus (gnome), and others. For each specific case, it depends on the DE wheather or not you can disable auto-restarting the desktop if it closes/crashes. If it doesn't interfere, you may be able to just kill the process. You may also be able to tell DE what to do via dbus (very case-specific).

It may be possible to have two desktop managers installed, in some cases, starting one replaces the other.

I realize this is not a complete answer, just a rough plan (too long to put in a comment). Feel free to comment on how to proceed in each particular case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.