Skip to content

Commit 906678c

Browse files
committed
1 parent 15261d8 commit 906678c

File tree

2 files changed

+290
-0
lines changed

2 files changed

+290
-0
lines changed

aqua/Ice/Portfile

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2+
3+
PortSystem 1.0
4+
PortGroup xcode 1.0
5+
PortGroup github 1.0
6+
7+
github.setup jordanbaird Ice 0.11.12
8+
github.tarball_from archive
9+
revision 0
10+
11+
homepage https://icemenubar.app/
12+
13+
categories aqua
14+
license GPL-3
15+
platforms {macosx >= 14}
16+
maintainers {gmail.com:herby.gillot @herbygillot} \
17+
openmaintainer
18+
19+
description Powerful menu bar manager for macOS
20+
21+
long_description \
22+
Ice is a powerful menu bar management tool for macOS. While its primary \
23+
function is hiding and showing menu bar items, it offers a wide range of \
24+
features to manage the menu bar. Items can be hidden or shown on demand, \
25+
rearranged via drag-and-drop, and searched. The menu bar appearance can \
26+
also be fully customized.
27+
28+
checksums rmd160 c02a7a7f7839254c5cac1ffa941abefcb43378a2 \
29+
sha256 6de28150c65d03bc17f80dc745eff15680903679a4dfe3b4bc88d46651761bb3 \
30+
size 16700295
31+
32+
patchfiles patch-disable-sparkle.diff
33+
34+
post-patch {
35+
# Remove Sparkle feed URL and public key from Info.plist
36+
set plist ${worksrcpath}/Ice/Info.plist
37+
system "/usr/libexec/PlistBuddy -c 'Delete :SUFeedURL' ${plist}"
38+
system "/usr/libexec/PlistBuddy -c 'Delete :SUPublicEDKey' ${plist}"
39+
}
40+
41+
xcode.scheme Ice
42+
xcode.configuration Release
43+
44+
# SPM generates sandbox profile temp files outside ${workpath}, which the
45+
# MacPorts build sandbox blocks from being read, causing sandbox_apply to fail.
46+
# Redirect all of Xcode's working state into ${workpath} to keep everything
47+
# within the sandbox-allowed tree.
48+
build.pre_args-append -derivedDataPath ${workpath}/derived-data \
49+
-clonedSourcePackagesDirPath ${workpath}/spm-packages
50+
51+
build.env-append TMPDIR=${workpath}/tmp \
52+
HOME=${workpath}/home
53+
54+
pre-build {
55+
file mkdir ${workpath}/tmp
56+
file mkdir ${workpath}/home/Library/Caches
57+
58+
# SPM sandboxes its manifest-loading subprocesses via sandbox-exec, but
59+
# macOS rejects nested sandbox_apply calls when the process is already
60+
# sandboxed by MacPorts. Allow sandbox-exec to run without inheriting
61+
# the MacPorts profile so it can apply its own profile successfully.
62+
append portsandbox_profile " (allow process-exec (literal \"/usr/bin/sandbox-exec\") (with no-profile))"
63+
}
64+
65+
xcode.build.settings-append \
66+
SDKROOT=macosx \
67+
DEVELOPMENT_TEAM= \
68+
CODE_SIGN_IDENTITY= \
69+
CODE_SIGNING_REQUIRED=NO \
70+
CODE_SIGN_ENTITLEMENTS= \
71+
ENABLE_USER_SCRIPT_SANDBOXING=NO \
72+
OTHER_SWIFT_FLAGS='-Xfrontend -disable-availability-checking'
73+
74+
destroot {
75+
copy ${worksrcpath}/build/${xcode.configuration}/Ice.app \
76+
${destroot}${applications_dir}/Ice.app
77+
}
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
--- Ice/Updates/UpdatesManager.swift
2+
+++ Ice/Updates/UpdatesManager.swift
3+
@@ -3,7 +3,6 @@
4+
// Ice
5+
//
6+
7+
-import Sparkle
8+
import SwiftUI
9+
10+
/// Manager for app updates.
11+
@@ -18,39 +17,11 @@
12+
/// The shared app state.
13+
private(set) weak var appState: AppState?
14+
15+
- /// The underlying updater controller.
16+
- private(set) lazy var updaterController = SPUStandardUpdaterController(
17+
- startingUpdater: true,
18+
- updaterDelegate: self,
19+
- userDriverDelegate: self
20+
- )
21+
-
22+
- /// The underlying updater.
23+
- var updater: SPUUpdater {
24+
- updaterController.updater
25+
- }
26+
-
27+
/// A Boolean value that indicates whether to automatically check for updates.
28+
- var automaticallyChecksForUpdates: Bool {
29+
- get {
30+
- updater.automaticallyChecksForUpdates
31+
- }
32+
- set {
33+
- objectWillChange.send()
34+
- updater.automaticallyChecksForUpdates = newValue
35+
- }
36+
- }
37+
+ var automaticallyChecksForUpdates: Bool = false
38+
39+
/// A Boolean value that indicates whether to automatically download updates.
40+
- var automaticallyDownloadsUpdates: Bool {
41+
- get {
42+
- updater.automaticallyDownloadsUpdates
43+
- }
44+
- set {
45+
- objectWillChange.send()
46+
- updater.automaticallyDownloadsUpdates = newValue
47+
- }
48+
- }
49+
+ var automaticallyDownloadsUpdates: Bool = false
50+
51+
/// Creates an updates manager with the given app state.
52+
init(appState: AppState) {
53+
@@ -59,87 +30,11 @@
54+
}
55+
56+
/// Sets up the manager.
57+
- func performSetup() {
58+
- _ = updaterController
59+
- configureCancellables()
60+
- }
61+
+ func performSetup() { }
62+
63+
- /// Configures the internal observers for the manager.
64+
- private func configureCancellables() {
65+
- updater.publisher(for: \.canCheckForUpdates)
66+
- .assign(to: &$canCheckForUpdates)
67+
- updater.publisher(for: \.lastUpdateCheckDate)
68+
- .assign(to: &$lastUpdateCheckDate)
69+
- }
70+
-
71+
/// Checks for app updates.
72+
- @objc func checkForUpdates() {
73+
- #if DEBUG
74+
- // Checking for updates hangs in debug mode.
75+
- let alert = NSAlert()
76+
- alert.messageText = "Checking for updates is not supported in debug mode."
77+
- alert.runModal()
78+
- #else
79+
- guard let appState else {
80+
- return
81+
- }
82+
- // Activate the app in case an alert needs to be displayed.
83+
- appState.activate(withPolicy: .regular)
84+
- appState.openSettingsWindow()
85+
- updater.checkForUpdates()
86+
- #endif
87+
- }
88+
+ @objc func checkForUpdates() { }
89+
}
90+
91+
-// MARK: UpdatesManager: SPUUpdaterDelegate
92+
-extension UpdatesManager: @preconcurrency SPUUpdaterDelegate {
93+
- func updater(_ updater: SPUUpdater, willScheduleUpdateCheckAfterDelay delay: TimeInterval) {
94+
- guard let appState else {
95+
- return
96+
- }
97+
- appState.userNotificationManager.requestAuthorization()
98+
- }
99+
-}
100+
-
101+
-// MARK: UpdatesManager: SPUStandardUserDriverDelegate
102+
-extension UpdatesManager: @preconcurrency SPUStandardUserDriverDelegate {
103+
- var supportsGentleScheduledUpdateReminders: Bool { true }
104+
-
105+
- func standardUserDriverShouldHandleShowingScheduledUpdate(
106+
- _ update: SUAppcastItem,
107+
- andInImmediateFocus immediateFocus: Bool
108+
- ) -> Bool {
109+
- if NSApp.isActive {
110+
- return immediateFocus
111+
- } else {
112+
- return false
113+
- }
114+
- }
115+
-
116+
- func standardUserDriverWillHandleShowingUpdate(
117+
- _ handleShowingUpdate: Bool,
118+
- forUpdate update: SUAppcastItem,
119+
- state: SPUUserUpdateState
120+
- ) {
121+
- guard let appState else {
122+
- return
123+
- }
124+
- if !state.userInitiated {
125+
- appState.userNotificationManager.addRequest(
126+
- with: .updateCheck,
127+
- title: "A new update is available",
128+
- body: "Version \(update.displayVersionString) is now available"
129+
- )
130+
- }
131+
- }
132+
-
133+
- func standardUserDriverDidReceiveUserAttention(forUpdate update: SUAppcastItem) {
134+
- guard let appState else {
135+
- return
136+
- }
137+
- appState.userNotificationManager.removeDeliveredNotifications(with: [.updateCheck])
138+
- }
139+
-}
140+
-
141+
// MARK: UpdatesManager: BindingExposable
142+
extension UpdatesManager: BindingExposable { }
143+
--- Ice/Settings/SettingsPanes/UpdatesSettingsPane.swift
144+
+++ Ice/Settings/SettingsPanes/UpdatesSettingsPane.swift
145+
@@ -6,66 +6,8 @@
146+
import SwiftUI
147+
148+
struct UpdatesSettingsPane: View {
149+
- @EnvironmentObject var appState: AppState
150+
-
151+
- private var updatesManager: UpdatesManager {
152+
- appState.updatesManager
153+
- }
154+
-
155+
- private var lastUpdateCheckString: String {
156+
- if let date = updatesManager.lastUpdateCheckDate {
157+
- date.formatted(date: .abbreviated, time: .standard)
158+
- } else {
159+
- "Never"
160+
- }
161+
- }
162+
-
163+
var body: some View {
164+
- IceForm {
165+
- IceSection {
166+
- automaticallyCheckForUpdates
167+
- automaticallyDownloadUpdates
168+
- }
169+
- if updatesManager.canCheckForUpdates {
170+
- IceSection {
171+
- checkForUpdates
172+
- }
173+
- }
174+
- }
175+
+ Text("Updates are managed by MacPorts.")
176+
+ .frame(maxWidth: .infinity, maxHeight: .infinity)
177+
}
178+
-
179+
- @ViewBuilder
180+
- private var automaticallyCheckForUpdates: some View {
181+
- Toggle(
182+
- "Automatically check for updates",
183+
- isOn: updatesManager.bindings.automaticallyChecksForUpdates
184+
- )
185+
- }
186+
-
187+
- @ViewBuilder
188+
- private var automaticallyDownloadUpdates: some View {
189+
- Toggle(
190+
- "Automatically download updates",
191+
- isOn: updatesManager.bindings.automaticallyDownloadsUpdates
192+
- )
193+
- }
194+
-
195+
- @ViewBuilder
196+
- private var checkForUpdates: some View {
197+
- HStack {
198+
- Button("Check for Updates…") {
199+
- updatesManager.checkForUpdates()
200+
- }
201+
- .controlSize(.large)
202+
-
203+
- Spacer()
204+
-
205+
- HStack(spacing: 2) {
206+
- Text("Last checked:")
207+
- Text(lastUpdateCheckString)
208+
- }
209+
- .lineLimit(1)
210+
- .font(.caption)
211+
- }
212+
- }
213+
}

0 commit comments

Comments
 (0)