diff --git a/src/lib/Guiguts/Preferences.pm b/src/lib/Guiguts/Preferences.pm index 4f772dd4..5c684e99 100644 --- a/src/lib/Guiguts/Preferences.pm +++ b/src/lib/Guiguts/Preferences.pm @@ -26,7 +26,7 @@ BEGIN { sub setdefaultpath { my ( $oldpath, $defaultpath, $forcedefault ) = @_; my $newpath = ''; - if ( -e $defaultpath or $forcedefault ) # If default path exists, consider it for new path + if ( -e $defaultpath or $forcedefault ) # If default path exists (or forced), consider it for new path { $newpath = $defaultpath; } else { # Otherwise check for no-extension version or elsewhere on path @@ -43,7 +43,7 @@ sub setdefaultpath { } $newpath = $oldpath unless $newpath; # Use oldpath if new path not found - if ( $newpath && -e $newpath ) { + if ( $newpath and ( -e $newpath or $forcedefault ) ) { my $index = index( $newpath, 'tools' ); $index = index( $newpath, 'scannos' ) if $index < 0; if ( $index >= 0 ) { # New path is in tools or scannos under the release @@ -67,11 +67,12 @@ sub setdefaultpath { # Either new and old have matching tails, or no suitable old - return relative path tail return $newtail; } else { # Not under tools subfolder - use old if it exists, otherwise use new default - return $oldpath if $oldpath && -e $oldpath; + print "PATHS1\n$oldpath\n$newpath\n\n" if $forcedefault; + return $oldpath if $oldpath && -e $oldpath; return $newpath; } } else { - print "PATHS\n$oldpath\n$defaultpath\n\n"; + print "PATHS2\n$oldpath\n$defaultpath\n\n" if $forcedefault; 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 16d128c8..e285540e 100644 --- a/src/lib/Guiguts/Utilities.pm +++ b/src/lib/Guiguts/Utilities.pm @@ -1256,29 +1256,33 @@ sub initialize { # If XnView or Aspell are installed under "Program Files (x86)", # set that as the default, otherwise use "Program Files" # Suitable for Windows installation locations - my $trypath = ::catfile( '\Program Files (x86)', 'XnView', 'xnview.exe' ); - if ( -e $trypath ) { - $::globalviewerpath = ::setdefaultpath( $::globalviewerpath, $trypath ); - } else { - $::globalviewerpath = ::setdefaultpath( $::globalviewerpath, - ::catfile( '\Program Files', 'XnView', 'xnview.exe' ) ); - } - $trypath = ::catfile( '\Program Files (x86)', 'Aspell', 'bin', 'aspell.exe' ); - if ( -e $trypath ) { - $::globalspellpath = ::setdefaultpath( $::globalspellpath, $trypath ); - } else { - $::globalspellpath = ::setdefaultpath( $::globalspellpath, - ::catfile( '\Program Files', 'Aspell', 'bin', 'aspell.exe' ) ); + if ($::OS_WIN) { + my $trypath = ::catfile( '\Program Files (x86)', 'XnView', 'xnview.exe' ); + if ( -e $trypath ) { + $::globalviewerpath = ::setdefaultpath( $::globalviewerpath, $trypath ); + } else { + $::globalviewerpath = ::setdefaultpath( $::globalviewerpath, + ::catfile( '\Program Files', 'XnView', 'xnview.exe' ) ); + } + $trypath = ::catfile( '\Program Files (x86)', 'Aspell', 'bin', 'aspell.exe' ); + if ( -e $trypath ) { + $::globalspellpath = ::setdefaultpath( $::globalspellpath, $trypath ); + } else { + $::globalspellpath = ::setdefaultpath( $::globalspellpath, + ::catfile( '\Program Files', 'Aspell', 'bin', 'aspell.exe' ) ); + } } # Override to more likely default locations for Mac if ($::OS_MAC) { # Force consideration of default Mac Preview command even though it doesn't "exist" as file path + print "PRE: $::globalviewerpath"; $::globalviewerpath = ::setdefaultpath( $::globalviewerpath, 'open -g -a Preview', 1 ); + print "POST: $::globalviewerpath"; # M1 and Intel-based Macs have some tools installed in different locations - $trypath = ::catfile( '/opt', 'homebrew', 'bin', 'aspell' ); + my $trypath = ::catfile( '/opt', 'homebrew', 'bin', 'aspell' ); if ( -e $trypath ) { $::globalspellpath = ::setdefaultpath( $::globalspellpath, $trypath ); } else {