Reputation: 348
I am looking for a way to programmatically get/set the icon positions on the desktop. Clearly there is some "state" stored somewhere. Does anybody know where?
I am trying to get a proof of concept going on ANY platform so if you know how to do it on XP in gnome, KDE or macOS.
Upvotes: 6
Views: 3999
Reputation: 715
In GNOME, Nautilus stores the position of icons and other stuff in ~/.nautilus/metafiles.
The files in there have ugly filenames, as they are really escaped URIs. For example, my metadata for my desktop icons lives in ~/.nautilus/metafiles/file:%2F%2F%2Fhome%2Ffederico%2FDesktop.xml
There is no public interface to access or modify that data, however. You can of course parse the file on your own and modify it, but the changes will not take effect until the next time you restart Nautilus.
Upvotes: 0
Reputation: 23311
A lot of the answers here are saying that doing this sort of thing is pretty difficult to do in Windows. I suspect that this is not by accident. If you've never read Raymond Chen's blog The Old New Thing I suggest you do. Mr. Chen frequently discusses the pitfalls and abuse that occur with programmatic access to things such as the placement of icons.
Edit: Here are some commentaries about allow programmatic access in Windows.
Although you're probably not meant to be able to do this (at least on Windows), that doesn't mean that it can't be done. I just ask that you do this in the spirit of good and not evil.
Upvotes: 1
Reputation: 34243
Position of normal files and folders is stored in the hidden .DS_Store file, that exists for any directory The position of volume icons on Mac OS X seems to be stored in the Finders .plist (~/Library/Preferences/com.apple.finder).
Upvotes: 1
Reputation: 1912
I've tried looking into this a couple of times the last couple of years, it seems like such a trivial thing (It was for the AmigaDos workbench), but programming for the Windows shell is ugly; actually programming anything in the Windows API is ugly. Its a horrible mess. Be prepared for a bunch of hair pulling and heart ache.
Not to discourage you, but MicroSoft thinks it knows best when it comes to icon placement in folder views and I have found little in a way to implement 'permanent' icon placement (I.e. Icon view is far from permanent). The MSDN docs offer little help in this regard (at least no examples). The last thing I looked into was writing a shell extension to record and restore icon position (I wouldn't record these in the registry, I was just going to store positions in the folder's desktop.ini file, but it would probably be better to create a file in the user's private settings folder).
Code Project has a number of articles on shell programming and extensions.
http://www.codeproject.com/KB/shell/ http://www.codeproject.com/KB/shell/shlext.aspx
I ended up writing my own little shell in nice clean pure C++ that does exactly what I want in the context of my application.
Upvotes: 0