Skip to content

Commit

Permalink
fix compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyun6 committed Dec 19, 2024
1 parent d772324 commit 16c3b15
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions QuickRecorder/QuickRecorderApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import ServiceManagement
import CoreMediaIO
import Sparkle

var isMacOS12 = true
var isMacOS14 = false
var isMacOS15 = false
let isMacOS12 = ProcessInfo.processInfo.operatingSystemVersion.majorVersion == 12
let isMacOS14 = ProcessInfo.processInfo.operatingSystemVersion.majorVersion == 14
let isMacOS15 = ProcessInfo.processInfo.operatingSystemVersion.majorVersion == 15
var scPerm = false
let fd = FileManager.default
let ud = UserDefaults.standard
Expand Down Expand Up @@ -167,6 +167,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, SCStreamDelegate, SCStreamOu
}

func applicationWillFinishLaunching(_ notification: Notification) {
scPerm = SCContext.updateAvailableContentSync() != nil

let process = NSWorkspace.shared.runningApplications.filter({ $0.bundleIdentifier == "com.lihaoyun6.QuickRecorder" })
if process.count > 1 {
DispatchQueue.main.async {
Expand All @@ -176,7 +178,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, SCStreamDelegate, SCStreamOu
}

lazy var userDesktop = (NSSearchPathForDirectoriesInDomains(.desktopDirectory, .userDomainMask, true) as [String]).first!
//let saveDirectory = (UserDefaults(suiteName: "com.apple.screencapture")?.string(forKey: "location") ?? userDesktop) as NSString

ud.register( // default defaults (used if not set)
defaults: [
Expand All @@ -193,7 +194,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, SCStreamDelegate, SCStreamOu
"countdown": 0,
"videoFormat": VideoFormat.mp4.rawValue,
"pixelFormat": PixFormat.delault.rawValue,
//"colorSpace": ColSpace.srgb.rawValue,
"encoder": Encoder.h264.rawValue,
"poSafeDelay": 1,
"saveDirectory": userDesktop as NSString,
Expand All @@ -218,19 +218,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, SCStreamDelegate, SCStreamOu
ud.setValue(false, forKey: "showPreview")
ud.setValue(false, forKey: "remuxAudio")
}

UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in
if let error = error { print("Notification authorization denied: \(error.localizedDescription)") }
}

scPerm = SCContext.updateAvailableContentSync() != nil

let os = ProcessInfo.processInfo.operatingSystemVersion
isMacOS12 = os.majorVersion == 12
isMacOS14 = os.majorVersion == 14
isMacOS15 = os.majorVersion == 15

//if !ud.bool(forKey: "showOnDock") { NSApp.setActivationPolicy(.accessory) }

var allow : UInt32 = 1
let dataSize : UInt32 = 4
let zero : UInt32 = 0
Expand All @@ -240,9 +232,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, SCStreamDelegate, SCStreamOu
mElement: CMIOObjectPropertyElement(kCMIOObjectPropertyElementMain))
CMIOObjectSetPropertyData(CMIOObjectID(kCMIOObjectSystemObject), &prop, zero, nil, dataSize, &allow)

//statusMenu.delegate = self
statusBarItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
//statusBarItem.menu = statusMenu
statusBarItem.button?.image = NSImage()

mousePointer.title = "Mouse Pointer".local
Expand Down

0 comments on commit 16c3b15

Please sign in to comment.