mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
57 lines
1.6 KiB
Swift
57 lines
1.6 KiB
Swift
//
|
|
// BundleInfos.swift
|
|
// DynamicIsland
|
|
//
|
|
// Created by Richard Kunkli on 08/08/2024.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
extension Bundle {
|
|
var releaseVersionNumber: String? {
|
|
return infoDictionary?["CFBundleShortVersionString"] as? String
|
|
}
|
|
var buildVersionNumber: String? {
|
|
return infoDictionary?["CFBundleVersion"] as? String
|
|
}
|
|
var releaseVersionNumberPretty: String {
|
|
return "v\(releaseVersionNumber ?? "1.0.0")"
|
|
}
|
|
|
|
var iconFileName: String? {
|
|
guard let icons = infoDictionary?["CFBundleIcons"] as? [String: Any],
|
|
let primaryIcon = icons["CFBundlePrimaryIcon"] as? [String: Any],
|
|
let iconFiles = primaryIcon["CFBundleIconFiles"] as? [String],
|
|
let iconFileName = iconFiles.last
|
|
else { return nil }
|
|
return iconFileName
|
|
}
|
|
}
|
|
|
|
struct BundleAppIcon: View {
|
|
var body: some View {
|
|
Bundle.main.iconFileName
|
|
.flatMap { NSImage(named: $0) }
|
|
.map { Image(nsImage: $0) }
|
|
}
|
|
}
|
|
|
|
func isNewVersion() -> Bool {
|
|
let defaults = UserDefaults.standard
|
|
let currentVersion = Bundle.main.releaseVersionNumber ?? "1.0"
|
|
let savedVersion = defaults.string(forKey: "LastVersionRun") ?? ""
|
|
|
|
if currentVersion != savedVersion {
|
|
defaults.set(currentVersion, forKey: "LastVersionRun")
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func isExtensionRunning(_ bundleID: String) -> Bool {
|
|
if let _ = NSWorkspace.shared.runningApplications.first(where: {$0.bundleIdentifier == bundleID}) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|