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*.