Skip to content

Commit

Permalink
Try forcing Mac default image open command
Browse files Browse the repository at this point in the history
  • Loading branch information
windymilla committed Dec 2, 2023
1 parent 9ce845d commit de8440f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/lib/Guiguts/Preferences.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/lib/Guiguts/Utilities.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down

0 comments on commit de8440f

Please sign in to comment.