|
|
#1 |
|
Prospect
Join Date: Mar 2003
Posts: 4
|
How to set CD background image programmatically?
There are several CD's that have a background image. Like MS Office for OSX or BBEdit 7.0.
I was wondering how to set CD background image programmatically? The current way is to do CMD-J and then choose the image. Is there an alternative way of doing that from the terminal or using an AppleScript? |
|
|
|
|
|
#2 |
|
MVP
Join Date: Jan 2002
Posts: 1,562
|
I intended on posting what I thought was an answer to this query - but it turns out I don't know the answer. I swear I had this info somewhere.
Anyway - the info regarding the background file is stored in a hidden file on the disk image called ".DS_store". I believe this file is simply a data fork file containing various data about the disk image. I was unable to edit the file except with a resource editor. Couple of items for you to ponder and maybe they will spark a solution... Its fairly easy to alter resources (including data 'df' resources) as seen in the .DS_store files using AppleScript. You can use the command line utility xxd to convert the .DS_store binary file to a ASCII file that you could then modify through programmatic means, then use xxd to convert it back to binary form again after editing. For example: Code:
# to view a binary file in the terminal xxd /path/to/file # /Volumes/diskImageName/.DS_Store # # to edit binary file # # export binary as ASCII to a file xxd -p /path/to/file > /path/to/output.txt # modify file as desired here... # return file to binary format xxd -pr /path/to/file.txt > /path/to/output |
|
|
|
|
|
#3 |
|
Triple-A Player
Join Date: Oct 2002
Location: Labadie, MO
Posts: 136
|
I replied over in this thread at the beginning of last month. This question seems to come up about once a month.
I originally stole and slightly modified this procedure from this page. Anyway, without further ado:
Last edited by eravau; 03-26-2003 at 09:58 PM. |
|
|
|
|
|
#4 |
|
MVP
Join Date: Jan 2002
Posts: 1,562
|
thx eravau - good info, but I think the question at hand is how can you do all that via a shell script or applescript.
|
|
|
|
|
|
#5 |
|
Prospect
Join Date: Mar 2003
Posts: 4
|
Thanks for the info folks.
However, I have been playing around with the .DS_Store file. In the case of background pictures, the information is not stored there. I used the CMD-J technique to create a background successfully but the .DS_Store file was NOT created even after I unmounted and mounted the disk image, the background picture was set correctly but there were no changes to any file at the root of the .dmg or elsewhere. It is stored somewhere internally... |
|
|
|
|
|
#6 |
|
MVP
Join Date: Jan 2002
Posts: 1,562
|
I did the exact same test...
1. Create new read/write disk image and mount. 2. Add background graphic file to disk. 3. Use Finder to select background graphic for disk image. 4. Unmount and remount dmg I then inspect and sure enough .DS_Store is on disk. Peer into it and you will see the graphic file name too. |
|
|
|
|
|
#7 |
|
Prospect
Join Date: Mar 2003
Posts: 4
|
BlueHz, you are probably right about the .DS_Store file having the information. Ity is written out when .dmg is unmounted by the Finder.
The .DS_Store file is there the next time I mount the .dmg even though I deleted it before unmounting the .dmg. Where is xxd available online? Or any pointers to the AppleScript to modify the .DS_Store files? Why couldn't they have simply used .plst file for such information too.... |
|
|
|
|
|
#8 |
|
Major Leaguer
Join Date: Dec 2002
Posts: 441
|
Customize your .dmg's window exactly as you like it, unmount and remount the .dmg, then copy the resultant .DS_Store file to another location on your hard disk [/YourDMG-sourcefiles] (which you also want to contain a copy of the .jpg file). Then rename your .DS_Store model under another name:
cd /Volumes/YourDMG ditto .DS_Store /YourDMG-sourcefiles/DS_Store-model (Note that we are copying the original .DS_Store file to a stationary path on your main hard disk for later retrieval.) Then, to customize future DMGs: ditto /YourDMG-sourcefiles/DS_Store-model /Volumes/YourDMG/.DS_Store ditto /YourDMG-sourcefiles/your.jpg /Volumes/YourDMG/your.jpg /Developer/Tools/SetFile -a V /Volumes/YourDMG/your.jpg hdiutil unmount /Volumes/YourDMG hdiutil mount /YourDMG-sourcefiles/your.dmg should do the trick. (Once you have the technique working, you can leave off the last step. We are only mounting it again to confirm that the custom window settings are preserved.) This can be automated in a shell script (once the source files are set up and in place) or through AppleScript (using its native language or in conjunction with the do shell script syntax). |
|
|
|
|
|
#9 |
|
MVP
Join Date: Jan 2002
Posts: 1,562
|
thx gatorparrots - your technique still requires using the Finder at least once. I would like a technique that could be completely shell scripted. Seems like it should be possible - I just don't have the unix skills yet.
For example - using a background file called "404.jpg". I can look inside the .DS_Store file and see the filename listed: cd /Volumes/test xxd .DS_Store will hexdump the contents of the .DS_Store... here is a partial listing Code:
0000000: 0000 0001 4275 6431 0000 1000 0000 0800 ....Bud1........ 0000010: 0000 1000 0000 0108 0000 0000 0000 0000 ................ 0000020: 0000 0000 0000 0000 0000 0000 0000 0800 ................ 0000030: 0000 0800 0000 0000 0000 0000 0000 0000 ................ 0000040: 0000 0000 0000 0002 0000 0000 0000 0004 ................ 0000050: 0000 0001 0000 1000 6f62 0000 0010 009d ........ob...... 0000060: 010e 0232 0000 0000 0000 0000 0000 0000 ...2............ 0000070: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000080: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000090: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00000a0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00000b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00000c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00000d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00000e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00000f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000100: 0000 0000 0000 0000 0000 0004 0000 0001 ................ 0000110: 002e 6677 6930 626c 6f62 0000 0010 009d ..fwi0blob...... 0000120: 010e 0232 0375 6963 6e76 0001 0000 0000 ...2.uicnv...... 0000130: 0001 002e 6677 7668 7368 6f72 0000 0149 ....fwvhshor...I 0000140: 0000 0001 002e 6963 7370 626c 6f62 0000 ......icspblob.. 0000150: 0008 0000 0000 0000 0000 0000 0007 0034 ...............4 0000160: 0030 0034 002e 006a 0070 0067 496c 6f63 .0.4...j.p.gIloc 0000170: 626c 6f62 0000 0010 0000 01ac 0000 0090 blob............ 0000180: ffff ffff ffff 0000 0000 0000 0000 0000 ................ Code:
xxd -s 0x000015f -l 13 .DS_Store 000015f: 3400 3000 3400 2e00 6a00 7000 67 4.0.4...j.p.g I think if we could solve that - we would be halfway to a fully scripted method. Changing the filename in the hexdump is not so hard to do - but I am not sure how the format of the .DS_Store is setup - for example the length of the data. What happens to the data after the filename, etc. |
|
|
|
|
|
#10 |
|
Prospect
Join Date: Mar 2003
Posts: 4
|
gatorparrots,
Your tecnique works but a refinement is (so that the Finder does NOT OVERWRITE your .DS_Store with junk from memory) is to FORCE restart the Finder with a simple AppleScript that forces the Finder to quit and then restart again... This step needs to be performed after the background image has been made invisible! |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|