Go Back   The macosxhints Forums > OS X Help Requests > System



Reply
 
Thread Tools Rate Thread Display Modes
Old 03-25-2003, 10:17 PM   #1
shada
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?
shada is offline   Reply With Quote
Old 03-26-2003, 06:43 AM   #2
bluehz
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
bluehz is offline   Reply With Quote
Old 03-26-2003, 12:14 PM   #3
eravau
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:
  • Run Disk Copy and make a new blank disk image. I'm calling mine thingie.
  • Copy the background image file (say logo.jpg) to the mounted disk image volume
  • Open the disk image volume, choose Show View Options from the View menu (or press commmand-J). Make sure you select This window only so that you don't get every window, everywhere.
  • Choose Picture from the Background section, press the Select... button and select the logo.jpg that's on the thingie drive.
  • Resize your window as appropriate.
  • Run the following in the terminal to hide the logo.jpg file (Note that this requires you to have the Developer Tools installed):
    /Developer/Tools/SetFile -a V /Volumes/thingie/logo.jpg
  • Unmount thingie and re-mount it.
  • You should now see your image, and no visible picture file icon.
That's it.

Last edited by eravau; 03-26-2003 at 09:58 PM.
eravau is offline   Reply With Quote
Old 03-26-2003, 12:28 PM   #4
bluehz
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.
bluehz is offline   Reply With Quote
Old 03-26-2003, 04:14 PM   #5
shada
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...
shada is offline   Reply With Quote
Old 03-26-2003, 11:32 PM   #6
bluehz
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.
bluehz is offline   Reply With Quote
Old 03-27-2003, 03:13 AM   #7
shada
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....
shada is offline   Reply With Quote
Old 03-27-2003, 05:32 AM   #8
gatorparrots
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).
gatorparrots is offline   Reply With Quote
Old 03-27-2003, 08:17 AM   #9
bluehz
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  ................
you will notice that at offset 000015f you will see the name of the background file "404.jpg"
Code:
xxd -s 0x000015f -l 13 .DS_Store
000015f: 3400 3000 3400 2e00 6a00 7000 67         4.0.4...j.p.g
So the question is - what is the format used here to store the filename?

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.
bluehz is offline   Reply With Quote
Old 04-20-2003, 05:14 PM   #10
shada
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!
shada is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 09:59 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.