3

I'm using Ubuntu MATE 20.04 LTS. There are a lot carefully aligned icons on my desktop. Something like shown below:

icons

I can't find icon positions attributes in dconf / gsettings.

How can I backup their current positions to restore them later? Where such a file is located?

N0rbert
  • 103,263

2 Answers2

5

Quick greping in home folder gives the following file name with needed information:

~/.local/share/gvfs-metadata/home

It is special file to be operated by gio info or gio set.


Every icon has its own metadata attribute. So one can:

  • read it by

    gio info -a "metadata::caja-icon-position" ~/Desktop/file1.txt
    

    to get something like

    attributes:
      metadata::caja-icon-position: 922,382
    

    where 922 and 382 are horizontal and vertical pixel positions for file1.txt icon.

  • write it by

    gio set -t string ~/Desktop/file1.txt metadata::caja-icon-position 300,400
    

    to move file1.txt icon to the location specified by 300 and 400 coordinates in pixels.

    Then one needs to ask Caja to refresh the desktop by calling caja -q.

N0rbert
  • 103,263
3

I wrote a bash script that will save and load icon positions. Usage is

./icons.sh save [name]
./icons.sh load [name]

The name argument is optional, in case you want to save different configurations. You may have to adjust the lines under #config info to accommodate your OS.

#!/bin/bash

#config info desktop=~/Desktop/* metastr="metadata::caja-icon-position" metafile=~/.config/caja/desktop-metadata saveicon=~/.icon.txt savemeta=~/.iconmeta.txt file_manager=caja

saveinfo(){ cat /dev/null > "$saveicon" for f in $desktop;do p=$(gio info -a "$metastr" "$f"|grep "$metastr"|awk '{print $2}') echo "$f;$p">>"$saveicon" done #save metafile cp "$metafile" "$savemeta" zenity --notification --window-icon="/usr/share/icons/gnome/48x48/categories/applications-other.png" --text "Icon Positions Saved" }

loadinfo(){ str=$(cat "$saveicon") if [ -z "$str" ];then echo "$saveicon not found" exit fi

for fl in $str;do f=$(echo "$fl"|cut -d';' -f1) p=$(echo "$fl"|cut -d';' -f2) gio set -t string "$f" "$metastr" "$p" done #load metafile cp "$savemeta" "$metafile" #restart file manager pkill "$file_manager" }

if [ -z "$1" ];then echo "Saves or loads icon positions" echo " Usage:" echo "$0 save [name]" echo "$0 load [name]" exit fi

if [ -n "$2" ];then saveicon="$2" savemeta="$2_meta" fi

if [ "$1" = "save" ];then saveinfo fi

if [ "$1" = "load" ];then loadinfo fi

Ken H
  • 326