From de8440fb3e20a63099002b3f2ec6e8f6ee30689c Mon Sep 17 00:00:00 2001 From: Nigel Date: Sat, 2 Dec 2023 17:04:20 +0000 Subject: [PATCH] Try forcing Mac default image open command --- src/lib/Guiguts/Preferences.pm | 7 ++++--- src/lib/Guiguts/Utilities.pm | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/lib/Guiguts/Preferences.pm b/src/lib/Guiguts/Preferences.pm index 32598bfa..4f772dd4 100644 --- a/src/lib/Guiguts/Preferences.pm +++ b/src/lib/Guiguts/Preferences.pm @@ -24,12 +24,12 @@ BEGIN { # we just keep the tail end (relative) path which will work wherever this release # is installed. sub setdefaultpath { - my ( $oldpath, $defaultpath ) = @_; + my ( $oldpath, $defaultpath, $forcedefault ) = @_; my $newpath = ''; - if ( -e $defaultpath ) # If default path exists, consider it for new path + if ( -e $defaultpath or $forcedefault ) # If default path exists, consider it for new path { $newpath = $defaultpath; - } else { # Otherwise check for no-extension version or elsewhere on path + } else { # Otherwise check for no-extension version or elsewhere on path my ( $basename, $filepath, $suffix ) = fileparse( $defaultpath, ( ".exe", ".com", ".bat" ) ); my $filename = "$basename$suffix"; @@ -71,6 +71,7 @@ sub setdefaultpath { return $newpath; } } else { + print "PATHS\n$oldpath\n$defaultpath\n\n"; return ( $oldpath ? $oldpath : $defaultpath ); # If all else fails return old path, or if empty, the default path } } diff --git a/src/lib/Guiguts/Utilities.pm b/src/lib/Guiguts/Utilities.pm index 92146518..16d128c8 100644 --- a/src/lib/Guiguts/Utilities.pm +++ b/src/lib/Guiguts/Utilities.pm @@ -1273,8 +1273,9 @@ sub initialize { # Override to more likely default locations for Mac if ($::OS_MAC) { - $::globalviewerpath = ::setdefaultpath( $::globalviewerpath, - ::catfile( '/Applications', 'XnViewMP.app', 'Contents', 'MacOS', 'XnViewMP' ) ); + + # Force consideration of default Mac Preview command even though it doesn't "exist" as file path + $::globalviewerpath = ::setdefaultpath( $::globalviewerpath, 'open -g -a Preview', 1 ); # M1 and Intel-based Macs have some tools installed in different locations $trypath = ::catfile( '/opt', 'homebrew', 'bin', 'aspell' );