get desktop position isn't working for volumes

let’s assume you have a hard disk of name “Macintosh HD” on your Desktop. now run this script

tell application "Finder" to set desktop position of item "Macintosh HD" of desktop to {100, 100}

and it should have moved “Macintosh HD” to position to {100, 100}. and, in fact,

tell application "Finder" to get desktop position of item "Macintosh HD" of desktop
--> {100, 100}

now drag “Macintosh HD” on the Desktop to a new position and then rerun

tell application "Finder" to get desktop position of item "Macintosh HD" of desktop
--> {100, 100}

clearly not correct.

this doesn’t happen for non-volume icons.

is there a way around this?

thanks,

i have something that works, but it may not be general

tell application "Finder" to set theDisk to name of startup disk (* let's assume it's on desktop *)
set cmd to "| sed 's/;//g' | awk '/." & theDisk & "_0x.*/ {getline; print $3; getline; getline; print $3; getline; print $3; exit}' | sed 's/\"//g'"
set theList to (do shell script "defaults read com.apple.finder FXDesktopVolumePositions " & cmd)

set td to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set list1 to (text items of theList)
set AppleScript's text item delimiters to td

tell application "Finder" to copy the bounds of the window of desktop to the ScreenSize
set x to 0
set y to 0
set anchor to item 1 of list1 as integer
if anchor = 1 or anchor = 2 then set x to item 3 of ScreenSize
if anchor = 2 or anchor = 3 then set y to item 4 of ScreenSize
{x + (item 2 of list1) as integer, y + (item 3 of list1) as integer}

assuming your startup disk is on the desktop, if you drag it to a new position and wait (until com.apple.finder.plist updates), then the result will be the location.

will fail, most likely, if you drag the icon to a second monitor or the first entry in FXDesktopVolumePositions is not relevant but the last is.

i’ld like something better, of course.

cheers,

gp

going back to the original post. if after dragging the volume icon, you fast user switch to another account and then come back, then get desktop position works for volume icons.

anyone want to guess what is called during fast user switching so that AS works afterwards? Restarting the Finder doesn’t work.