Hi,
I’m trying to make a script to do that :
1 - Mount image (a sparse bundle image)
2 - When mounted, launch app (Lightroom)
3 - When I’m quitting the app (LightRoom), just unmount the image.
To do that, I’m trying to use a script found here :
http://hints.macworld.com/article.php?story=20040905112951299
And, after changing some parameters, steps 1 and 2 are working well. But step 3 doesn’t work : when I quit Lightroom, the image is not unmounted.
The script :
property diskname : "Catalogue-Lightroom"
property diskpath : "Données Aurélie:Permanent:Catalogue-Lightroom.sparsebundle"
property itemname : "Macintosh HD:Applications:Adobe Photoshop Lightroom 4.app"
property appname : "Adobe Photoshop Lightroom 4.app"
on run
tell application "Finder"
if not (exists the disk diskname) then
do shell script ("hdiutil attach " & quoted form of ¬
POSIX path of (diskpath as string) & " -mount required")
repeat until name of every disk contains diskname
delay 1
end repeat
end if
open item itemname
end tell
delay 5
end run
-- remainder based on hint by puffyn at macosxhints.com:
-- hint named "Quick Applescript to Mount Disk Image"
-- shell script to get devname by Dale Mox with fixes by jbc
on idle
set devname to do shell script "mount | grep " & diskname & ¬
" | cut -f1-1 -d \" \" | cut -f3-3 -d \"/\""
tell application "Finder"
if not (exists the disk diskname) then
return
else
set x to the name of every process
if appname is not in x then
do shell script ("hdiutil unmount /Volumes/" & diskname & " -force")
do shell script ("hdiutil detach " & devname & " -force")
tell me to quit
end if
end if
end tell
return 2
end idle