Prevent icons moving at login or boot [SOLVED]

Post Reply
Message
Author
wsxian2
Posts: 3
Joined: Mon Sep 18, 2017 8:57 pm

Prevent icons moving at login or boot [SOLVED]

#1 Post by wsxian2 »

My wife has been driven crazy with her icons moving around on her after she has set them on her desktop the way she wanted them.
We were using MX 18.1 and I down graded her back to 16 but similar problem.
I read some items on the forum about saving the current icon setting file located in /home/USERNAME/.config/xfce4/desktop into a subdirectory of that directory (make one up such as "myicons").
Then create a shell script that deletes the files in /home/USERNAME/.config/xfce4/desktop and copies the file from the made up directory into the /home/USERNAME/.config/xfce4/desktop.
It works, but every time my wife moves an icon or adds an icon the system creates a new icon file (in the above directory) such as icons.screen0-1664x993.rc. And there could be a lot of them in the directory and you have to find the latest one by date, then copy that into the made up directory ("myicons") and edit the shell scrip to update the name of the icon file.
Gets old after a while.

I did some more research today and found this link: https://forum.xfce.org/viewtopic.php?id=12447 which gives two files which solves the problem.
The first shell script (he has a newer version in his second post and you should use that one) needs to be copied to an editor such as FeatherPad then save it to a directory (I used /home/USERNAME/) with a file name you need to remember (NAMEOFFILE).
You will need to make it executable by opening up the xfce terminal and using the ls and cd command, move to the directory wherein the file is located.
Then issue this command: chmod +x NAMEOFFILE
You may need to issue the su command and enter the admin password and try again.
This file requires inotify-tools and that is normally not part of the MX distribution so while in the terminal you need to issue the su command and input the admin password and then type: "apt-get install inotify-tools".
inotify-tools will then install
leave the terminal open
Now you need to open up "Settings" in the MX menu then "Session and Startup" then click on the tab "Application Autostart"
Then click on the "+Add" button and a dialog box will appear with 3 fields to fill in.
In "Name" put in something you want to remember such as 'Icon-saver" and under "Description" put something to remember what this does such as "Resets icons"
Then under "Command" you need to put "bash -c NAMEOFFILE" make sure you put the entire path such as "/home/USERNAME/NAMEOFFILE"
Close by clicking on the OK button.

Go back to the xfce terminal and type in the following command after making sure you are in the correct directory where the file (NAMEOFFILE) is located (use ls command and see if the file is listed): "./NAMEOFFILE"
if nothing happens, then use the su command then type in the admin password and try again.
you should get a message that says "Watches established".
if not, close other programs and try again.
Do not close the terminal, but move one of the desktop icons to a new place on the desktop screen and you should see a notification "Icon position saved" and then a long file name.
If this happens, you are now set to work on the next file.

The second shell script (he has a newer version in his second post and you should use that one) also needs to be copied to an editor such as FeatherPad then save it to the desktop (/home/USERNAME/Desktop) with a file name you need to remember (NAMEOFFILE).
The shell script has a block of text with the following "#ans=$(zenity --title "Save With Exit" --height 300 --width 200 --list --text " etc.
Just delete this block of text as MX uses yad so you should only have the line (or block): ans=$(yad --window-icon=system-devices-panel-information --on-top --sticky --f" etc.
save (if you don't do this, nothing is hurt as the default use for the file is to use yad and the shell script has placed the zenity block in a remark anyway)
You will need to make it executable by opening up the xfce terminal and using the ls and cd command, move to the Desktop directory wherein the file is located.
Then issue this command: chmod +x NAMEOFFILE
You may need to issue the su command and enter the admin password and try again.
Close the terminal.
You should see the icon on your desktop. You will use this icon to logout, shutdown, restart or hibernate your MX session. Do not use the normal method from now on, you should use this icon.
Test it by clicking on the icon and a dialog box should come up and allow you to choose logout, shutdown, restart, etc.
For now, just click cancel.
If you want to put this on the MX main menu then right click on the Main MX Menu icon with the right mouse button, then click on "Properties" then click on the "Commands" tab, then click on the browse button for "Log Out" and find the "NAMEOFFILE" for the second file you just created, then click on it and it should show in the field for "Log Out". Now click on the"Close" button. If you ever decide to go back to the old method, just put back "xfce4-session-logout" in that field.
Well done. What these files do is: the first file saves the latest icon file after an icon has been moved or added to the desktop, and upon exiting your MX session the second file prevents the xcfe4 system from changing the icons to the default all left positions and the first file automatically directs xcfe4 to use the saved icon file so that your icon positions remain as they were.

AND IT WORKS! :eek:
For power users, I have deliberately put in a lot of information for newbies like myself.

User avatar
towwire
Posts: 648
Joined: Fri Oct 15, 2010 12:15 pm

Re: Prevent icons moving at login or boot [SOLVED]

#2 Post by towwire »

Nice find.
Here is what I've been using for some time. It's not automatic, Is done manual.

Save desktop icons

Code: Select all

[Desktop Entry]
Version=1.0
Name=Save Icons
Comment=Save desktop icons.
Comment[de]=Speichert die aktuelle Position der Desktopicons.
# fehlix - 11.11.18
# mx-forum: https://forum.mxlinux.org/viewtopic.php?f=104&t=46907
Exec=/bin/bash -c 'D=~/.config/xfce4/desktop; S=$D.save; [ -d $S ] || mkdir -p $S; rm -f $S/icons* 2>/dev/null; cp $D/icons* $S; notify-send  --icon=package-downgrade "Icons saved"'
Icon=package-downgrade
Type=Application
Categories=Utility;
OnlyShowIn=XFCE;
Path=
Terminal=false
StartupNotify=false
Restore Icons

Code: Select all

[Desktop Entry]
Version=1.0
Name=Restore Icons
Type=Application
Comment=Restore desktop icons.
Comment[de]=Die aktuelle Position der Desktop-Icons wiederherstellen.
# fehlix - 11.11.18
# mx-forum: https://forum.mxlinux.org/viewtopic.php?f=104&t=46907
Exec=/bin/bash -c 'D=~/.config/xfce4/desktop; S=$D.save; [ -d $S ] || exit; ls  $S/icons* 2>/dev/null 1>/dev/null && rm -f $D/icons*; cp $S/icons* $D;xfdesktop --reload 2>/dev/null; notify-send  --icon=package-upgrade "Icons Restored"'
Icon=package-upgrade
Categories=Utility;
OnlyShowIn=XFCE;
Terminal=false
StartupNotify=false
Path=
I've have thought about putting the Restore Icons into autostart, but have not tried it. I only restart my system about every 3 weeks, so no big deal.
It is easier to fight for one's principles then to live up to them.

kangburra
Posts: 54
Joined: Wed Jul 31, 2019 3:10 am

Re: Prevent icons moving at login or boot [SOLVED]

#3 Post by kangburra »

I have found the problem is due to the desktop being resized, my solution is to have invisible (or not) locked panels on each side, this allows for my real panel to hide and to use Plank on the other side. Once they are in place the icons stay put.

Post Reply

Return to “XFCE Desktop Environment”