How to make a 'dmg' file which opens in list view

Hi,
This is a simple example of making a ‘dmg’ file containing a single item selected in the finder:


tell application "Finder"
	activate
	set theItem to item 1 of (selection as alias list)
	set theItemPath to quoted form of POSIX path of theItem as string
	set dmgFileName to name of theItem as string
	set theItemContainerPath to POSIX path of (container of theItem as string)
	set dmgFileNamePath to quoted form of (theItemContainerPath & dmgFileName & ".dmg")
	try
		do shell script "hdiutil create -srcfolder " & theItemPath & " -volname " & quoted form of dmgFileName & " " & dmgFileNamePath
	end try
end tell

My problem is that the ‘dmg’ file opens by default in icon view, while I need it to open in list view.
Is there any way to make a ‘dmg’ file which opens by default in list view? The ‘man hdiutil’ isn’t very helpful for that.
Many thanks for any solution.

Hello.

This doesn’t help a whole lot, but you can make Finder to show the dmg.file in list view. I think that you want the dmg file to open in list view once it mounts. I don’t have any experience with that, but at least you could have a shell script with an icon in your dmg file, with the name list view, that executes an osa script, telling finder to show it as list view.

If it is you that wants it in listview, then you can also create a launchd process, that triggers when the dmg file is mounted.

There may be other things to achieve the same, hopefully.

Edit

if pressing cmd 1 is totally out of question, then, maybe you can create a disk with a CD-format, and create an AUTORUN.INF file.

I have no idea if that is possible, but that would be it, if it is.

Thanks McUsrII,

I have no problem with setting the list view when I need it. Unfortunately, it’s not for my own use. By company policy, we email, ftp or download sets of processed files and folders as standard ‘dmg’ files to various clients. Many of them seem to prefer to have them opening in list view by default – “the client is always right” (unless I disagree).

Regarding the CD format, I don’t know, it sounds outdated, cumbersome and not really standard ‘dmg’.

There must be a way make ‘dmg’ files which open in list view by default, because I do have a few such files, admittedly commercially produced files. Since they exist, there must be a way to write them. But how? – is the question.

The view is a property of Finder, not of your dmg file, but .

if you store your dmg file as a list view, then maybe that view gets stored in the .DS_Store file, but I guess you have tried that already. Maybe you can do something to see to that the default view of the folder that becomes the DMG file is listview?

It is something to test! :slight_smile:

My work Mac is setup by default to list view and the finished sets are assembled in folders in list view, but it doesn’t make any difference. As soon as a folder is converted to folder_name.dmg, it opens in icon view.

I’m still searching. I see all sorts of tricks in the appearance of open commercial ‘dmg’ files. There must be a way to code all that.

Well. Maybe you should try to change the setup, and the save it, when that window is open, and try open it again, to see that it is indeed saved like this.

You would have to choose list view, then change something under Show → Options, (or whatever). Then you check to see that a .DS_Store file is there. Then you close the window, and reopen it, and checks that it indeed retain the settings you made the first time. When this is passed, you should try to make a DMG file and open it, and see if it too has those options.

Somewhere around it should turn a choice to “always open in listview”. And exactly this method should work, as I would never have seen any Dmg files that opens beautifully with a background image.

Hi

i’m sure if you incorporate your script into the work flow suggested below you’ll get what your after

http://pixelcorps.cachefly.net/mbkd_010_540p_h264.mov

Sal’s the man!

He said that you could just adjust the look of it, and it would open like that when opened again, and by others.

The point is to make that .DS_Store file being saved to the image, it won’t if the disk image is sized to fit.

I can’t do that without using that workflow, the image that is made is a read/write image.

I have tried to do with a read only image, but it doesn’t seem to work

Thanks, that seems to do what I want but the actual script is difficult to follow in the movie. Is there anywhere to view the layout or download that Automator script?

Just make it, it is two actions.

“Get finder selection”, then “create disk-file”. You can do the same with a read write disk image, created with disk utility, from a folder, if you set read/write.

If that is a problem for you, read write, then you create an md5-checksum of the files. So you are guaranteed that the files are like you sent them, should you ever wonder.

not that i’m aware of, i just followed what Sal was doing and built the action with no issues, maybe pause the movie and go back over it a few times, works pretty well.

So Budgie, do you mange to create a read only image that opens in list view?

Curious, if it is just me. If you manage, please share.

I think of putting a zipfile on an image, as an alternative, there I believe you can have .DS_Store file inside, but then it isn’t a mounted volume anymore, when unpacked. But in list-view. :slight_smile:

I believe in this, at least for Snow Leopard: 10.6: Set the View type for a Disk Image - Mac OS X Hints But it only works for read/write images.

“read only”, sorry must have missed that, i was just supplying an idea for the work flow, maybe add a script to make it read only during creation process some how.

Hello.

It seems to me that the .DS_store is a read/write file, so the diskutil doesn’t seem to bother to carry it with it, when it converts the read/write thing to a read only thing.

I can’t wait to try this with a disk image with an image in the background, hopefully that is an easier process, without read/write! :slight_smile:

I had now time to try this. It doesn’t really do what I need. It makes the disk image successfully and leaves it mounted in list view. But then, as soon as you close the image window and reopen it, it opens in icon view. If you unmount the disk image and then remount it, it opens directly in icon view.

This automator workflow may have worked in whatever OS X version they had in the video, but in Lion and ML the list view is not persistent.

I tried this as well but it doesn’t work. The .DS_Store file is discarded when the read-only disk image is created (our ‘dmg’ files have to be read-only).

So, I’m still looking for a solution :frowning:

Hello.

I gave this some more thoughts yesterday. Obviously, Dmg’s for installing software (The good looking ones, with a background image, and an alias or symbolic link to your applications folder, where you can drop the app), aren’t write protected.

I can live with that, I also think that I can write protect files. It is not so, that someone is after screwing you, and if they remove a write protected file, and starts screwing with it, it is their own fault.

A solution that works, before people starts to be nefarious, is to deliver the dmg-file embededded in a zip file, that way the users/customers always will have access to a fresh copy.

Actually, you can set an attribute, that makes Safari unpack such files automatically, which is not what you want. Just mentioning it for completion.

Hello.

I also think that you may be able to regulate what a user can do with the files on your read writeable dmg, with a combination of ownership, regular file attributes, and access control lists, (acl). I think that even if the user owns the image, after they have downloaded it, you are still the owner of the file.

You would test how it works, by creating, or using another account on your system without administrator rights, and see how the dmg behaves there.

I don’t have the time to follow up on that, but I guess there is copy inhibit options or acl’s that can simulate a copy inhibit, which will hinder the user from moving a file off the dmg.

You should really inspect a dmg image with a deliverable on it, and see how they did it. Looking at it from Disk utility, and from the shell.

GetFileInfo resides in /Developer/tools, acl’s are described in man chmod and man chflags.

You may also have to issue a command, to enable acl’s on your dmg volume, I am not sure how to do that, the command used in Tiger was named fsaclctl but it seems to be gone, maybe there are some interesting info in : [url=http://images.apple.com/support/security/guides/docs/Leopard_Security_Config_2nd_Ed.pdf]http://images.apple.com/support/security/guides/docs/Leopard_Security_Config_2nd_Ed.pdf[/url]

Realistically, it will take you around 4 hours to make a solution that works.

It takes a wink of an eye to press command-2, or a second to first hit the libelle, then hit the list view icon.

I’d tell the users, who has problems with this, that I bet they can’t remember to press command-2 in order to get the window into list view.

I’d also tell them that command-2 is an expensive keystroke, It has a fine of 200 Euro for not remembering it. :slight_smile:

I hate to give up, but making ‘dmg’ files to open in list view by default seems to be “a bridge too far”.

Anyway, I do like your idea :lol: