Home > bash, coding, linux, xfce > Backup/restore XFCE desktop icons

Backup/restore XFCE desktop icons

Sometimes the XFCE desktop icons get messed up, for example by games that temporarily change the screen resolution to 800×600.

A solution to this problem has been mentioned here. It suggests using “sudo chattr +i” to lock the config file where XFCE stores the icon positions.

Alternatively (and without the repeated need for sudo and chattr) you can also backup and restore the ~/.config/xfce4/desktop/icons* file(s) like this:

Create a script /usr/local/bin/save-xfce-desktop-icons.sh like this:

#! /bin/sh
mkdir -p ~/.config/xfce4/desktop.bak
cp -f ~/.config/xfce4/desktop/icons* ~/.config/xfce4/desktop.bak

Create another script /usr/local/bin/load-xfce-desktop-icons.sh like this:

#! /bin/sh
cp -f ~/.config/xfce4/desktop.bak/icons* ~/.config/xfce4/desktop

Make the scripts executable like this

sudo chmod ugo+x /usr/local/bin/save-xfce-desktop-icons.sh
sudo chmod ugo+x /usr/local/bin/load-xfce-desktop-icons.sh

Then in the XFCE start menu, go to “Settings” – “Keyboard” – “Application Shortcuts” and configure 2 keyboard shortcuts:

Command Shortcut
save-xfce-desktop-icons.sh <Control><ALT>S
load-xfce-desktop-icons.sh <Control><ALT>L

Then you will be able to backup and restore your icons like this:

  • Backup: Press F5 then <Control><ALT>S then F5
  • Restore: Press F5 then <Control><ALT>L then F5

The F5 is necessary to synchronize what you see on the screen with the content of ~/.config/xfce4/desktop/icons*.

Advertisements
Categories: bash, coding, linux, xfce
  1. Script
    January 4, 2016 at 04:14

    Thanks for useful post,
    this is my version in one script:

    for backup positions:
    $ desktop_icons_script.sh -b

    for restore positions:
    $ desktop_icons_script.sh -r

    — desktop_icons_script.sh ———————————————-

    #!/bin/bash
    DIR_BACKUP=~/.config/xfce4/desktop.backup
    DIR_RAPLACE=~/.config/xfce4/desktop

    if [ “$1” = -b ]; then
    # — backup —
    mkdir -p $DIR_BACKUP
    cp -f $DIR_RAPLACE/icons* $DIR_BACKUP
    notify-send -i gtk-add “`date +%Y.%m.%d\ %H:%M:%S`” “Icons position backuped!”
    fi
    if [ “$1” = -r ]; then
    # — restore —
    cp -f $DIR_BACKUP/icons* $DIR_RAPLACE
    xfdesktop -R
    notify-send -i gtk-refresh “`date +%Y.%m.%d\ %H:%M:%S`” “Icons position restored!”
    fi
    #END

    ————————————————————————————-

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: