Converting from nautilus to caja desktop icons

I recently upgraded from Gnome2 to… mate. Let’s not get into the reasons, since this is just about solving the desktop icons.

So getting straight to it: in nautilus, all the metadata about files as they appear in the GUI (so: icon position, size, emblems, etc) exist in a series of files in $HOME/.local/share/gvfs-metadata
(each file in there related to a filesystem)

caja, on the other hand, uses the SAME FILES – but sometimes different metadata.

So, when I moved from gnome2/nautilus to mate/caja, I found that my desktop icons retained their same sizes, emblems… but not location.

Why is this so?

So if you try running this:

bounty:~ $ gvfs-info -a "metadata::*" ~Desktop

You should get a bunch of output, something like:

attributes:
metadata::annotation:
metadata::emblems: [certified, desktop, system]
metadata::icon-scale: 1
metadata::nautilus-default-view: OAFIID:Nautilus_File_Manager_List_View
metadata::nautilus-icon-position: 1432,-3
metadata::nautilus-icon-position-timestamp: 1226057199
metadata::nautilus-icon-view-auto-layout: true
metadata::nautilus-icon-view-sort-by: name
metadata::nautilus-icon-view-tighter-layout: false
metadata::nautilus-icon-view-zoom-level: 1
metadata::nautilus-list-view-sort-column: date_modified
metadata::nautilus-list-view-sort-reversed: true
metadata::nautilus-list-view-zoom-level: 1
metadata::nautilus-window-geometry: 857x761+2017+96
metadata::nautilus-window-scroll-position: file:///home/nemo/Desktop/sunpath

If you’ve been playing with caja already, you’ll have some “metadata::caja-*” attributes too.

So in a nutshell, metadata::emblems and metadata::icon-scale naturally enough are seen by caja as easily as nautilus, but metadata::nautilus-icon-position is invisible to caja, which expects to see metadata::caja-icon-position.

Converting from one to the other is almost trivial. Lookup the value with gvfs-info, then set the value with gvfs-set-attribute.

Right?

Not quite.

I did that, and while the relative positions of my desktop icons were correct, they were too far apart (and so: some were off the screen)

For reasons I do not know (and for all I know, are specific to some quirk in my personal setup), I had to scale all the geometry values down by approx a third. (for the record, that means my caja-icon-position seems to be based off my screen resolution, whilst nautilus’ were not?

Anyway, my final solution was this short script (I named it gvfs2matevfs)

#!/bin/bash

iconpos=$(gvfs-info -a "metadata::nautilus-icon-position" "$@" | grep nautilus-icon-position | awk -F: '{print $4}')

# so by my estimate, caja-icon-position is about 2/3 the value of nautilus-icon-position
if [ -n "$iconpos" ] ; then
  ex=$(( ${iconpos%,*} * 67/100))
  wy=$(( ${iconpos#*,} * 67/100))
  gvfs-set-attribute -t string "$@" "metadata::caja-icon-position" $ex,$wy
  echo "$* $iconpos : $ex,$wy"
fi

I then ran this this thusly (note: from the Desktop)

bounty:~/Desktop $ find . -maxdepth 1 -print0 | xargs -0 -n 1 ~/bin/gvfs2matevfs

And (after refreshing the desktop icons by moving to an empty workspace and hitting F5) viola, there they are, where I want them! :)

(oh, and you’ll have to run all the above from within a running mate/caja environment, otherwise gvfs isn’t visible)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>