Skip to content

Commit

Permalink
Update macOS update notification to better fit the new menu bar item.…
Browse files Browse the repository at this point in the history
… Needs more love to replace the icon. Might require an additional binary...
  • Loading branch information
michaelherger committed Sep 18, 2024
1 parent 2bc5eb5 commit a523b75
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ runs:
sudo cp -nf platypus /usr/local/bin
sudo chmod +x /usr/local/bin/platypus
# required by create-dmg if we want to get a customized icon
# required by create-dmg if we want to get a customized icon - https://github.com/sindresorhus/create-dmg
brew install -q graphicsmagick imagemagick
Expand Down
15 changes: 10 additions & 5 deletions Bin/darwin/check-update.pl
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ BEGIN
Slim::Utils::OSDetect::init();

if ( my $installer = Slim::Utils::Light->checkForUpdate() ) {

# run the preference pane
require File::Basename;
my $pwd = File::Basename::dirname($0);
`osascript $pwd/openprefs.scpt`;
# new Menubar Item would pass localized strings for a notification
if (@ARGV) {
`osascript -e 'display notification "$ARGV[0]" with title "$ARGV[1]"'`;
}
# legacy: run the preference pane
else {
require File::Basename;
my $pwd = File::Basename::dirname($0);
`osascript $pwd/openprefs.scpt`;
}
}

1;
2 changes: 1 addition & 1 deletion Changelog9.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h2><a name="v9.0.0" id="v9.0.0"></a>Introducing... Lyrion Music Server Version
<ul>
<li><a href="https://github.com/LMS-Community/slimserver-platforms/pull/64">#64</a> - Upgrade Docker base image to Debian 12 (Bookworm) - thanks @mavit!</li>
<li>Much improved RPM packages to better integrate with system standards (thanks @JohanSaaw!)</li>
<li>New macOS integration: replace the preference pane with a menubar item.</li>
<li>New macOS integration: replace the preference pane with a menubar item (requires macOS 10.11 El Capitan).</li>
<li>Update Windows 64-bit installer to be compatible with new Windows on ARM machines.</li>
</ul>
<br />
Expand Down
19 changes: 12 additions & 7 deletions Slim/Utils/OS/OSX.pm
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,10 @@ sub getDefaultGateway {
my $updateCheckInitialized;
my $plistLabel = "com.slimdevices.updatecheck";

sub initUpdate { if (!IS_MENUBAR_ITEM) {
sub initUpdate {
return if $updateCheckInitialized;

my $log = Slim::Utils::Log::logger('server.update');
$log->error(IS_MENUBAR_ITEM ? 'menu item' : 'nope');

return if IS_MENUBAR_ITEM;

my $err = "Failed to install LaunchAgent for the update checker";

Expand All @@ -388,6 +385,13 @@ sub initUpdate { if (!IS_MENUBAR_ITEM) {
require File::Basename;
my $folder = File::Basename::dirname($script);

my $moreParams;
if (IS_MENUBAR_ITEM) {
$moreParams = sprintf("<string>%s</string>", Slim::Utils::Strings::string('CONTROLPANEL_UPDATE_AVAILABLE'));
$moreParams .= sprintf("<string>%s</string>", Slim::Utils::Strings::string('SQUEEZEBOX_SERVER'));
$moreParams = Slim::Utils::Unicode::utf8off($moreParams);
}

print UPDATE_CHECKER qq(<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
Expand All @@ -397,6 +401,7 @@ sub initUpdate { if (!IS_MENUBAR_ITEM) {
<key>ProgramArguments</key>
<array>
<string>$script</string>
$moreParams
</array>
<key>RunAtLoad</key>
<true/>
Expand Down Expand Up @@ -429,16 +434,16 @@ sub initUpdate { if (!IS_MENUBAR_ITEM) {
unlink($launcherPlist);
$updateCheckInitialized = 0;
}, 'checkVersion' );
} }
}

sub getUpdateParams {
return {
cb => sub { if (!IS_MENUBAR_ITEM) {
cb => sub {
# let's kick the update checker
if ( my $err = `launchctl start $plistLabel` ) {
Slim::Utils::Log::logger('server.update')->error($err);
}
} }
}
};
}

Expand Down

0 comments on commit a523b75

Please sign in to comment.