From 2e132a0d2a6d4801b4fead0646e462f1ebe4996c Mon Sep 17 00:00:00 2001 From: Serena Date: Sat, 30 Sep 2023 01:09:11 +0300 Subject: [PATCH] make save location the user's chosen by default --- Azayaka/AppDelegate.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Azayaka/AppDelegate.swift b/Azayaka/AppDelegate.swift index 5b06a8d..5224731 100644 --- a/Azayaka/AppDelegate.swift +++ b/Azayaka/AppDelegate.swift @@ -37,7 +37,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, SCStreamDelegate, SCStreamOu let ud = UserDefaults.standard func applicationDidFinishLaunching(_ aNotification: Notification) { - let userDesktop = (NSSearchPathForDirectoriesInDomains(.desktopDirectory, .userDomainMask, true) as [String]).first + lazy var userDesktop = (NSSearchPathForDirectoriesInDomains(.desktopDirectory, .userDomainMask, true) as [String]).first! + + // the `com.apple.screencapture` domain has the user set path for where they want to store screenshots or videos + let saveDirectory = (UserDefaults(suiteName: "com.apple.screencapture")?.string(forKey: "location") ?? userDesktop) as NSString + ud.register( // default defaults (used if not set) defaults: [ "audioFormat": AudioFormat.aac.rawValue, @@ -45,7 +49,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, SCStreamDelegate, SCStreamOu "frameRate": 60, "videoFormat": VideoFormat.mp4.rawValue, "encoder": Encoder.h264.rawValue, - "saveDirectory": userDesktop!, + "saveDirectory": saveDirectory, "hideSelf": false ] )