9

I'd like to programmatically access and manipulate the Desktop icon positions, their icons, etc.

This is for files and directories that you keep in ~/Desktop .

Where is this stuff stored?

David
  • 263
  • 3
  • 10

1 Answers1

9

Stored as GVFS metadata attributes.

To get all GVFS metadata attributes for file/directory:

gvfs-info '/home/user/Desktop/Untitled Folder/'

To get specific attribute - icon position:

gvfs-info -a 'metadata::nautilus-icon-position' '/home/user/Desktop/Untitled Document/'

To set icon position:

gvfs-set-attribute -t string '/home/user/Desktop/Untitled Document/' 'metadata::nautilus-icon-position' '500,500'

Remember to refresh desktop (F5 key) to see effect.

If lower level manipulation required there is Nautilus Extension API (via libnautilus):

https://developer.gnome.org/libnautilus-extension/stable/

and specifically:

https://developer.gnome.org/libnautilus-extension/stable/NautilusFileInfo.html

dess
  • 682
  • 1
  • 8
  • 16
  • This works well for actual files; is it also possible to access `metadata::nautilus-icon-position` for the special icons that appear on the desktop for USB drives, ‘Home’, etc? `gvfs-info -a 'metadata::nautilus-icon-position' '/home/user/Desktop/External-drive'` says “No such file or directory”. – Honore Doktorr Jan 11 '17 at 22:17
  • The commands are now `gio info` and `gio set`, for example on Ubuntu 18.04. – David Oct 27 '18 at 02:25
  • With the gio utility: To get all metadata attributes for file/directory: `gio info '/home/user/Desktop/Untitled Folder/'` To set icon position: `gio set --type=string '/home/user/Desktop/Untitled Folder/' 'metadata::nautilus-icon-position' '500,500'` – PaulRM Jan 27 '20 at 13:40