2

In Ubuntu 16.04 LTS, I'm writing a Bash script to align Desktop icons with a custom grid. For this, I need to retrieve each file's icon position on the Desktop.

Following suggestions here, I tried running this command in the terminal for particular files and folders...

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

...but no information is output to the terminal except the file uri and an empty attributes: line.

When I run this more general command...

sudo gvfs-info -a "*" /home/user/Desktop/*

...I find that none of the files on the Desktop have any attributes prefixed with metadata::, much less anything resembling nautilus-icon-position.

For example, the above command gives this info for one folder on the Desktop...

display name: wishlist
edit name: wishlist
name: wishlist
type: directory
size:  4096
uri: file:///home/user/Desktop/wishlist
attributes:
  standard::type: 2
  standard::name: wishlist
  standard::display-name: wishlist
  standard::edit-name: wishlist
  standard::copy-name: wishlist
  standard::icon: folder
  standard::content-type: inode/directory
  standard::fast-content-type: inode/directory
  standard::size: 4096
  standard::allocated-size: 4096
  standard::symbolic-icon: folder-symbolic, folder
  etag::value: 1477080349:564939
  id::file: l44:401458
  id::filesystem: l44
  access::can-read: TRUE
  access::can-write: TRUE
  access::can-execute: TRUE
  access::can-delete: TRUE
  access::can-trash: TRUE
  access::can-rename: TRUE
  time::modified: 1477080349
  time::modified-usec: 564939
  time::access: 1487319742
  time::access-usec: 474841
  time::changed: 1487319742
  time::changed-usec: 470842
  unix::device: 44
  unix::inode: 401458
  unix::mode: 16895
  unix::nlink: 15
  unix::uid: 1000
  unix::gid: 1000
  unix::rdev: 0
  unix::block-size: 4096
  unix::blocks: 8
  owner::user: user
  owner::user-real: user
  owner::group: user

How, then, can I get (and set) the icon position for each file on the desktop?

Be Brilliant
  • 113
  • 1
  • 5
  • Not on Unity/ nautilus (and not at home) atm, but see: http://askubuntu.com/a/796996/72216 don't use sudo... – Jacob Vlijm Feb 17 '17 at 10:28
  • Thanks. Although I don't know any Python, this is a step in the right direction. I used sudo, b/c gvfs-info was giving me a "Permission Denied" message, without it. The script that you suggested rearranges the icons by name. Ideally I want to snap icons to a grid without rearranging them by name or type-- just snap to closest grid position. Would appreciate any help with this, when you have time, b/c Unity's default grid works very poorly, for my needs. – Be Brilliant Feb 17 '17 at 10:39
  • I certainly will, but I need to be on my own system. Please ask! I will write an answer anyway when I get home (if it's no dupe of the linked one), if the question was not answered before that. If you have 20+ rep we can switch to chat. – Jacob Vlijm Feb 17 '17 at 10:42
  • Unfortunately, I don't have enough rep to chat, yet. I tried script that you linked to, above. I put it in a file and ran `python3 /home/user/bin/arrange-desktop` but terminal says repeatedly `GVFS-WARNING **: can't init metadata tree /home/user/.local/share/gvfs-metadata/home: open: Permission denied. Error setting attribute: Error setting file metadata: can't open metadata tree`. I tried again with `sudo python3...` and that stopped "permission denied" errors, but then terminal says repeatedly, `Error setting attribute: Setting attribute metadata::nautilus-icon-position not supported`. – Be Brilliant Feb 17 '17 at 11:17

0 Answers0