FastDMG icon indicating copy to clipboard operation
FastDMG copied to clipboard

Support for Finder alternatives

Open probablykasper opened this issue 3 years ago • 3 comments

FastDMG doesn't seem to work when replacing Finder with an alternative like Path Finder (You can make Path Finder default in Preferences > General > Set as the default file browser).

Finder can also be disabled using this command:

launchctl unload -w /System/Library/LaunchAgents/com.apple.Finder.plist

probablykasper avatar Apr 29 '22 15:04 probablykasper

My guess is that FastDMG is still doing its job, but the mounted image is not opened in the non-Finder file browser. FastDMG contains this code to open the mounted image:

[[NSWorkspace sharedWorkspace] openFile:mountPoint withApplication:@"Finder" andDeactivate:YES];

As far as I know, there is no way to "generically open a directory in the user's file system browser of choice" on macOS. Only the Finder, unless I were to hack together some nasty AppleScript with explicit support for Path Finder ... which is not going to happen. 99%+ of people just use the Finder, bad as it is.

sveinbjornt avatar Nov 17 '22 13:11 sveinbjornt

Users can easily create their own workaround with apps like EventScripts (available on the Mac App Store). There's a "volume mounted" trigger, and you can attach a shell script etc. to that trigger. In my case, I'm using Nimble Commander, so on my system I would then run something like this:

volumepath="$3"
if diskutil info "$volumepath" | grep -q -m 1 "Protocol:.*Disk Image" &>/dev/null ; then
	osascript -e 'activate application "Nimble Commander"' -e 'tell application "System Events" to keystroke "t" using command down'
	open -a "Nimble Commander" "$volumepath"
fi

I guess it would also work with Path Finder too. You just need to check if CMD-T is the shortcut for opening a new tab—it probably is—, and also check if open -a "Path Finder" "$volumepath" would work, i.e. whether it opens "$volumepath" in the newly created tab, or if you need to use another line of osascript to tell Path Finder to reveal the volume path.

JayBrown avatar May 22 '23 11:05 JayBrown

My guess is that FastDMG is still doing its job, but the mounted image is not opened in the non-Finder file browser. FastDMG contains this code to open the mounted image:

[[NSWorkspace sharedWorkspace] openFile:mountPoint withApplication:@"Finder" andDeactivate:YES];

As far as I know, there is no way to "generically open a directory in the user's file system browser of choice" on macOS. Only the Finder, unless I were to hack together some nasty AppleScript with explicit support for Path Finder ... which is not going to happen. 99%+ of people just use the Finder, bad as it is.

FastDMG could also send a proprietary NSDistributedNotification for a volume mount containing the full volume path as data (POSIX path). Then users could just compile their own observer for the NSDistributedNotificationCenter and add the above shell script behind it. That way, the user could ensure that the script is only executed, if a disk image has actually been mounted by FastDMG, and not by some other process.

PS: EventScripts doesn't allow users to add their own observers, so it would only work with some quick Objective-C tinkering on the user's part.

JayBrown avatar May 22 '23 11:05 JayBrown