Skip to content

Commit

Permalink
Add preference to update to beta versions #250
Browse files Browse the repository at this point in the history
  • Loading branch information
melonamin committed Feb 18, 2022
1 parent 9cefbbd commit bda1802
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 4 deletions.
7 changes: 7 additions & 0 deletions SwiftBar/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, SPUStandardUserDriverDelegat
return pluginManager.getPluginByNameOrID(identifier: identifier)
}

func feedURLString(for _: SPUUpdater) -> String? {
if prefs.includeBetaUpdates {
return "https://swiftbar.github.io/SwiftBar/appcast-beta.xml"
}
return "https://swiftbar.github.io/SwiftBar/appcast.xml"
}

func application(_: NSApplication, open urls: [URL]) {
for url in urls {
switch url.host?.lowercased() {
Expand Down
8 changes: 8 additions & 0 deletions SwiftBar/PreferencesStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class PreferencesStore: ObservableObject {
case StreamablePluginDebugOutput
case PluginDebugMode
case StealthMode
case IncludeBetaUpdates
}

let disabledPluginsPublisher = PassthroughSubject<Any, Never>()
Expand Down Expand Up @@ -80,6 +81,12 @@ class PreferencesStore: ObservableObject {
}
}

@Published var includeBetaUpdates: Bool {
didSet {
PreferencesStore.setValue(value: includeBetaUpdates, key: .IncludeBetaUpdates)
}
}

var makePluginExecutable: Bool {
guard let out = PreferencesStore.getValue(key: .MakePluginExecutable) as? Bool else {
PreferencesStore.setValue(value: true, key: .MakePluginExecutable)
Expand Down Expand Up @@ -114,6 +121,7 @@ class PreferencesStore: ObservableObject {
terminal = .Terminal
shell = .Bash
swiftBarIconIsHidden = PreferencesStore.getValue(key: .HideSwiftBarIcon) as? Bool ?? false
includeBetaUpdates = PreferencesStore.getValue(key: .IncludeBetaUpdates) as? Bool ?? false
if let savedTerminal = PreferencesStore.getValue(key: .Terminal) as? String,
let value = TerminalOptions(rawValue: savedTerminal)
{
Expand Down
4 changes: 1 addition & 3 deletions SwiftBar/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>358</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>INIntentsSupported</key>
<array>
<string>GetPluginsIntent</string>
Expand All @@ -57,7 +57,5 @@
<string>Copyright ©2020-2021 Ameba Labs. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>SUFeedURL</key>
<string>https://swiftbar.app/release.xml</string>
</dict>
</plist>
1 change: 1 addition & 0 deletions SwiftBar/Resources/Localization/Localizable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ enum Localizable {
case Terminal = "PF_TERMINAL"
case Shell = "PF_SHELL"
case LaunchAtLogin = "PR_LAUNCH_AT_LOGIN"
case IncludeBetaUpdates = "PR_INCLUDE_BETA_UPDATES"
case HideSwiftBarIcon = "PF_HIDE_SWIFTBAR_ICON"
case UpdateLabel = "PF_CHECK_FOR_UPDATE"
case CheckForUpdates = "PF_CHECK_FOR_UPDATES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"PF_HIDE_SWIFTBAR_ICON" = "Hide SwiftBar Icon";
"PF_CHECK_FOR_UPDATE" = "Update";
"PF_CHECK_FOR_UPDATES" = "Check for updates";
"PR_INCLUDE_BETA_UPDATES" = "Enthalten Vorabversionen";
"PF_NO_PLUGINS_MESSAGE" = "Plugins folder is empty";
"PF_ENABLE_ALL" = "Enable All";
"PF_PLUGINS_FOOTNOTE" = "Enabled plugins appear in the menu bar.";
Expand Down
3 changes: 2 additions & 1 deletion SwiftBar/Resources/Localization/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"PF_TERMINAL" = "Terminal";
"PF_HIDE_SWIFTBAR_ICON" = "Hide SwiftBar Icon";
"PF_CHECK_FOR_UPDATE" = "Update";
"PF_CHECK_FOR_UPDATES" = "Check for updates";
"PF_CHECK_FOR_UPDATES" = "Check for Updates";
"PR_INCLUDE_BETA_UPDATES" = "Include Pre-Release Versions";
"PF_NO_PLUGINS_MESSAGE" = "Plugins folder is empty";
"PF_ENABLE_ALL" = "Enable All";
"PF_PLUGINS_FOOTNOTE" = "Enabled plugins appear in the menu bar.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"PF_HIDE_SWIFTBAR_ICON" = "Sakrij ikonu SwiftBara";
"PF_CHECK_FOR_UPDATE" = "Aktualiziraj";
"PF_CHECK_FOR_UPDATES" = "Traži nove verzije";
"PR_INCLUDE_BETA_UPDATES" = "Uključuju Verzije Prije Izdanja";
"PF_NO_PLUGINS_MESSAGE" = "Mapa dodataka je prazna";
"PF_ENABLE_ALL" = "Aktiviraj sve";
"PF_PLUGINS_FOOTNOTE" = "Aktivirani dodaci će se pojaviti u traci izbornika.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"PF_HIDE_SWIFTBAR_ICON" = "Verberg SwiftBar-icoon";
"PF_CHECK_FOR_UPDATE" = "Updates";
"PF_CHECK_FOR_UPDATES" = "Controleer op updates…";
"PR_INCLUDE_BETA_UPDATES" = "Pre-releaseversies Opnemen";
"PF_NO_PLUGINS_MESSAGE" = "Plug-insmap is leeg";
"PF_ENABLE_ALL" = "Alle plug-ins inschakelen";
"PF_PLUGINS_FOOTNOTE" = "Ingeschakelde plug-ins verschijnen in de menubalk.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"PF_HIDE_SWIFTBAR_ICON" = "Скрыть иконку SwiftBar";
"PF_CHECK_FOR_UPDATE" = "Обновить";
"PF_CHECK_FOR_UPDATES" = "Проверить обновления";
"PR_INCLUDE_BETA_UPDATES" = "Включая бета версии";
"PF_NO_PLUGINS_MESSAGE" = "Папка плагина пуста";
"PF_ENABLE_ALL" = "Включить все";
"PF_PLUGINS_FOOTNOTE" = "Включенные плагины видны в панели меню.";
Expand Down
2 changes: 2 additions & 0 deletions SwiftBar/UI/Preferences/GeneralPreferencesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ struct GeneralPreferencesView: View {
AppShared.checkForUpdates()
}
}
Toggle(Localizable.Preferences.IncludeBetaUpdates.localized, isOn: $preferences.includeBetaUpdates)
Spacer()
}
}
}
Expand Down

0 comments on commit bda1802

Please sign in to comment.