# ### backup-desktop.sh ### # #!/bin/bash # name and path of the script to be created (to be modified if necessary) file=~/restore_desktop.sh echo '#!/bin/bash'>$file icons_xy() { for i in ~/Desktop/* do echo -n gio set '"'"$i"'"';gio info --attributes=metadata::caja-icon-position "$i"|grep metadata done } icons_xy >>$file sed -i 's/n:/n/g' $file chmod u+x $file # focus the Desktop and simulate pressing F5 shortened to refresh the Desktop (to be adapted according to the Desktop used, here Mate) echo '/usr/local/bin/refresh-desktop.sh'>>$file # ### refresh-desktop.sh ### # #!/bin/bash echo "Getting Id for Desktop then refreshing it by simulating F5" # Get a list of window IDs for Caja window_ids=$(xdotool search --classname "desktop") # Iterate through each window ID for id in $window_ids; do # Get the window name for the current window ID window_name=$(xdotool getwindowname $id) echo "Checking ID $id : $window_name" # Check if the window name is "Desktop" if [[ "$window_name" == "Desktop" ]]; then # Run your script with the window ID echo "Found Desktop window with ID: $id" # Replace the following line with the script you want to run xdotool windowfocus --sync $id xdotool key F5 echo "Completed refreshing icons" exit 0 fi done # If no matching window was found echo "No Desktop window found." exit 0