DS_Store_Setup.scpt 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. -- Shamelessly taken from CMake source: Packaging/CMakeDMGSetup.scpt
  2. -- For licensing check cmake_modules/kitware license.txt
  3. --
  4. -- You can as well use this script to manually generate DS_Store
  5. -- First make DMG writable:
  6. -- hdiutil convert VCMI.dmg -format UDRW -o VCMI_writable.dmg
  7. -- Check current size of the image
  8. -- hdiutil resize -limits VCMI_writable.dmg
  9. -- Increase it size slightly so you can update .DS_Store
  10. -- Using 999999 will result in 512mb file though
  11. -- hdiutil resize -sectors 999999 VCMI_writable.dmg
  12. -- Attach it to /Volumes/VCMI/
  13. -- hdiutil attach VCMI_writable.dmg
  14. -- After run this script directly and it's will do the job
  15. -- osascript /path/to/vcmi/source/osx/DS_Store_Setup.scpt VCMI
  16. -- You should see icons moving and background appear
  17. -- Now /Volumes/VCMI/.DS_Store can be copied over to /path/to/vcmi/source/osx/dmg_DS_Stor
  18. on run argv
  19. set image_name to item 1 of argv
  20. tell application "Finder"
  21. tell disk image_name
  22. -- wait for the image to finish mounting
  23. set open_attempts to 0
  24. repeat while open_attempts < 4
  25. try
  26. open
  27. delay 1
  28. set open_attempts to 5
  29. close
  30. on error errStr number errorNumber
  31. set open_attempts to open_attempts + 1
  32. delay 10
  33. end try
  34. end repeat
  35. delay 5
  36. -- open the image the first time and save a DS_Store with just
  37. -- background and icon setup
  38. open
  39. set current view of container window to icon view
  40. set theViewOptions to the icon view options of container window
  41. set background picture of theViewOptions to file ".background:background.png"
  42. set arrangement of theViewOptions to not arranged
  43. set icon size of theViewOptions to 128
  44. delay 5
  45. close
  46. -- next setup the position of the app and Applications symlink
  47. -- plus hide all the window decoration
  48. open
  49. update without registering applications
  50. tell container window
  51. set sidebar width to 0
  52. set statusbar visible to false
  53. set toolbar visible to false
  54. set the bounds to { 400, 100, 900, 423 }
  55. set position of item "VCMI.app" to { 133, 140 }
  56. set position of item "Applications" to { 378, 140 }
  57. end tell
  58. update without registering applications
  59. delay 5
  60. close
  61. -- one last open and close so you can see everything looks correct
  62. open
  63. delay 5
  64. close
  65. end tell
  66. delay 1
  67. end tell
  68. end run