B5278B422A779CDB009F6462 /* BackendResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5278B412A779CDB009F6462 /* BackendResponse.swift */; };
B5278B452A77D924009F6462 /* CaptureSessionConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5278B442A77D924009F6462 /* CaptureSessionConfiguration.swift */; };
B5278B472A77E8D7009F6462 /* CapturaURLDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5278B462A77E8D7009F6462 /* CapturaURLDecoder.swift */; };
- B5278B4B2A7995AA009F6462 /* CloudStorage in Frameworks */ = {isa = PBXBuildFile; productRef = B5278B4A2A7995AA009F6462 /* CloudStorage */; };
B5278B4E2A799AA3009F6462 /* GetRemoteCaptures.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5278B4D2A799AA3009F6462 /* GetRemoteCaptures.swift */; };
B55403E72A79A08C004BCBAB /* CapturaShortcutsProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B55403E62A79A08C004BCBAB /* CapturaShortcutsProvider.swift */; };
B55403EA2A79A434004BCBAB /* ScriptedPreferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = B55403E92A79A434004BCBAB /* ScriptedPreferences.swift */; };
B5F915662A6EF80E007ECE8E /* CapturaTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5F915652A6EF80E007ECE8E /* CapturaTests.swift */; };
B5F915702A6EF80E007ECE8E /* CapturaUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5F9156F2A6EF80E007ECE8E /* CapturaUITests.swift */; };
B5F915722A6EF80E007ECE8E /* CapturaUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5F915712A6EF80E007ECE8E /* CapturaUITestsLaunchTests.swift */; };
+ B5F95FAF2A7AE7F1005EFFDA /* ConfigureCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5F95FAE2A7AE7F0005EFFDA /* ConfigureCommand.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
B5F9156B2A6EF80E007ECE8E /* CapturaUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CapturaUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
B5F9156F2A6EF80E007ECE8E /* CapturaUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CapturaUITests.swift; sourceTree = "<group>"; };
B5F915712A6EF80E007ECE8E /* CapturaUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CapturaUITestsLaunchTests.swift; sourceTree = "<group>"; };
+ B5F95FAE2A7AE7F0005EFFDA /* ConfigureCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigureCommand.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- B5278B4B2A7995AA009F6462 /* CloudStorage in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
children = (
B5278B482A781B78009F6462 /* Captura.sdef */,
B55403E92A79A434004BCBAB /* ScriptedPreferences.swift */,
+ B5F95FAE2A7AE7F0005EFFDA /* ConfigureCommand.swift */,
B55403EC2A7A388B004BCBAB /* RecordCommand.swift */,
);
path = Scripting;
);
name = Captura;
packageProductDependencies = (
- B5278B4A2A7995AA009F6462 /* CloudStorage */,
);
productName = Captura;
productReference = B5F9154E2A6EF80D007ECE8E /* Captura.app */;
);
mainGroup = B5F915452A6EF80D007ECE8E;
packageReferences = (
- B5278B492A7995AA009F6462 /* XCRemoteSwiftPackageReference "CloudStorage" */,
);
productRefGroup = B5F9154F2A6EF80D007ECE8E /* Products */;
projectDirPath = "";
B5278B212A71BFC3009F6462 /* OutputFormatSetting.swift in Sources */,
B55DDFCE2A6F069D001A5E76 /* RecordingWindow.swift in Sources */,
B55403ED2A7A388B004BCBAB /* RecordCommand.swift in Sources */,
+ B5F95FAF2A7AE7F1005EFFDA /* ConfigureCommand.swift in Sources */,
B5278B402A744297009F6462 /* Persistence.swift in Sources */,
B55DDFCC2A6F0253001A5E76 /* Notification+AppEvents.swift in Sources */,
B5F9155B2A6EF80E007ECE8E /* CapturaRemoteFile+name.swift in Sources */,
};
/* End XCConfigurationList section */
-/* Begin XCRemoteSwiftPackageReference section */
- B5278B492A7995AA009F6462 /* XCRemoteSwiftPackageReference "CloudStorage" */ = {
- isa = XCRemoteSwiftPackageReference;
- repositoryURL = "https://github.com/nonstrict-hq/CloudStorage";
- requirement = {
- kind = upToNextMajorVersion;
- minimumVersion = 0.4.0;
- };
- };
-/* End XCRemoteSwiftPackageReference section */
-
-/* Begin XCSwiftPackageProductDependency section */
- B5278B4A2A7995AA009F6462 /* CloudStorage */ = {
- isa = XCSwiftPackageProductDependency;
- package = B5278B492A7995AA009F6462 /* XCRemoteSwiftPackageReference "CloudStorage" */;
- productName = CloudStorage;
- };
-/* End XCSwiftPackageProductDependency section */
-
/* Begin XCVersionGroup section */
B5278B3C2A74420F009F6462 /* Captura.xcdatamodeld */ = {
isa = XCVersionGroup;
+++ /dev/null
-{
- "pins" : [
- {
- "identity" : "cloudstorage",
- "kind" : "remoteSourceControl",
- "location" : "https://github.com/nonstrict-hq/CloudStorage",
- "state" : {
- "revision" : "35700218d35579df091974b6e7765db94c83448b",
- "version" : "0.4.0"
- }
- }
- ],
- "version" : 2
-}
if let action = CapturaURLDecoder.decodeParams(url: url) {
switch action {
case let .configure(config):
- CapturaSettings.apply(config)
+ NotificationCenter.default.post(name: .setConfiguration, object: nil, userInfo: [
+ "config": config
+ ])
case let .record(config):
NotificationCenter.default.post(name: .setCaptureSessionConfiguration, object: nil, userInfo: [
"config": config
if let frame = notification.userInfo?["frame"] {
receivedFrame(frame as! CVImageBuffer)
}
+ case .setConfiguration:
+ DispatchQueue.main.async {
+ if let userInfo = notification.userInfo {
+ if let config = userInfo["config"] as? ConfigureAction {
+ self.setConfiguration(config)
+ }
+ }
+ }
case .reloadConfiguration:
- reloadConfiguration()
+ reloadConfiguration()
case .setCaptureSessionConfiguration:
if let userInfo = notification.userInfo {
if let config = userInfo["config"] as? RecordAction {
}
}
+ func setConfiguration(_ config: ConfigureAction) {
+ CapturaSettings.apply(config)
+ }
+
func reloadConfiguration() {
self.captureSessionConfiguration = CaptureSessionConfiguration()
}
static let failedtoUpload = Notification.Name("failedToUpload")
static let reloadConfiguration = Notification.Name("reloadConfiguration")
static let setCaptureSessionConfiguration = Notification.Name("setCaptureSessionConfiguration")
+ static let setConfiguration = Notification.Name("setConfiguration")
}
struct CapturaSettings {
static var frameRate: Int {
get {
- if NSUbiquitousKeyValueStore.default.object(forKey: "frameRate") == nil {
+ if UserDefaults.standard.object(forKey: "frameRate") == nil {
return 10
} else {
- return min(10, max(4, Int(NSUbiquitousKeyValueStore.default.longLong(forKey: "frameRate"))))
+ return min(10, max(4, UserDefaults.standard.integer(forKey: "frameRate")))
}
}
set {
- NSUbiquitousKeyValueStore.default.setValue(newValue, forKey: "frameRate")
+ UserDefaults.standard.setValue(newValue, forKey: "frameRate")
}
}
static var outputFormats: OutputFormatSetting {
get {
- OutputFormatSetting(rawValue: Int(NSUbiquitousKeyValueStore.default.longLong(forKey: "outputFormats"))) ?? .all
+ OutputFormatSetting(rawValue: UserDefaults.standard.integer(forKey: "outputFormats")) ?? .all
}
set {
- NSUbiquitousKeyValueStore.default.setValue(newValue.rawValue, forKey: "outputFormats")
+ UserDefaults.standard.setValue(newValue.rawValue, forKey: "outputFormats")
}
}
static var backend: URL? {
get {
- if let url = NSUbiquitousKeyValueStore.default.string(forKey: "backendUrl") {
+ if let url = UserDefaults.standard.string(forKey: "backendUrl") {
return URL(string: url)
}
return nil
}
set {
- NSUbiquitousKeyValueStore.default.setValue(newValue?.absoluteString, forKey: "backendUrl")
+ UserDefaults.standard.setValue(newValue?.absoluteString, forKey: "backendUrl")
}
}
static var backendFormat: OutputFormatSetting {
get {
- OutputFormatSetting(rawValue: Int(NSUbiquitousKeyValueStore.default.longLong(forKey: "backendFormat"))) ?? .gifOnly
+ OutputFormatSetting(rawValue: UserDefaults.standard.integer(forKey: "backendFormat")) ?? .gifOnly
}
set {
- NSUbiquitousKeyValueStore.default.setValue(newValue.rawValue, forKey: "backendFormat")
+ UserDefaults.standard.setValue(newValue.rawValue, forKey: "backendFormat")
}
}
static var shouldKeepLocalFiles: Bool {
get {
- if NSUbiquitousKeyValueStore.default.object(forKey: "keepFiles") == nil {
+ if UserDefaults.standard.object(forKey: "keepFiles") == nil {
return true
} else {
- return NSUbiquitousKeyValueStore.default.bool(forKey: "keepFiles")
+ return UserDefaults.standard.bool(forKey: "keepFiles")
}
}
set {
- NSUbiquitousKeyValueStore.default.set(newValue, forKey: "keepFiles")
+ UserDefaults.standard.set(newValue, forKey: "keepFiles")
}
}
static var shouldAllowURLAutomation: Bool {
get {
- NSUbiquitousKeyValueStore.default.bool(forKey: "allowURLAutomation")
+ UserDefaults.standard.bool(forKey: "allowURLAutomation")
}
set {
- NSUbiquitousKeyValueStore.default.setValue(newValue, forKey: "allowURLAutomation")
+ UserDefaults.standard.setValue(newValue, forKey: "allowURLAutomation")
}
}
import SwiftUI
-import CloudStorage
struct AdvancedSettings: View {
- @CloudStorage("backendUrl") var backendUrl: String = ""
- @CloudStorage("backendFormat") var backendFormat: OutputFormatSetting = .gifOnly
- @CloudStorage("keepFiles") var keepFiles = true
- @CloudStorage("allowURLAutomation") var allowURLAutomation = false
+ @AppStorage("backendUrl") var backendUrl: String = ""
+ @AppStorage("backendFormat") var backendFormat: OutputFormatSetting = .gifOnly
+ @AppStorage("keepFiles") var keepFiles = true
+ @AppStorage("allowURLAutomation") var allowURLAutomation = false
@State var showConfirmation = false
private var anyState: String { "\(backendUrl), \(backendFormat), \(keepFiles), \(allowURLAutomation)" }
import SwiftUI
-import CloudStorage
struct OutputSettings: View {
- @CloudStorage("outputFormats") var outputFormats: OutputFormatSetting = .all
- @CloudStorage("frameRate") var frameRate = 10.0
+ @AppStorage("outputFormats") var outputFormats: OutputFormatSetting = .all
+ @AppStorage("frameRate") var frameRate = 10.0
private var anyState: String { "\(outputFormats), \(frameRate)" }
<suite name="Captura Suite" code="CAPT" description="Controls Captura">
<class name="application" code="capp" description="The application's top-level scripting object.">
<cocoa class="CapturaApp"/>
- <property name="preferences" code="pPrp" type="preferences" access="r">
- <cocoa key="scriptedPreferences"/>
- </property>
</class>
- <class name="preferences" code="Cprf" description="The application preferences">
- <cocoa class="ScriptedPreferences"/>
+ <record-type code="CCRc" name="configuration">
<property name="fps" code="pPfp" type="integer" description="Sets the FPS of the recording" access="rw" />
<property name="outputs" code="pPou" type="text" description="Which outputs get generated locally" access="rw" />
<property name="backend" code="pPbk" type="text" description="Updates the backend URL that will be used" access="rw" />
<property name="backend_output" code="pPbo" type="text" description="Which output should be sent to the backend" access="rw" />
<property name="keep_local_files" code="pPlf" type="boolean" description="Whether to keep local files after a successful backend upload." access="rw"/>
- </class>
+ </record-type>
<record-type code="CCRr" name="recording_configuration">
<property name="x" code="CCrx" type="integer" description="Sets the starting horizontal position of the recording frame from the left of the screen. Defaults to the center of the screen." />
<property name="y" code="CCry" type="integer" description="Sets the starting vertical position of the recording frame from the bottom of the screen. Defaults to the center of the screen." />
<type type="recording_configuration" />
</direct-parameter>
</command>
+ <command name="configure" code="CCCMConf">
+ <cocoa class="ConfigureCommand" />
+ <direct-parameter description="The settings to be updated">
+ <type type="configuration" />
+ </direct-parameter>
+ </command>
</suite>
</dictionary>
--- /dev/null
+import Foundation
+
+@objc(ConfigureCommand)
+class ConfigureCommand: NSScriptCommand {
+ override func performDefaultImplementation() -> Any? {
+
+ let args = self.directParameter as? [String: Any] ?? [:]
+
+ // Here you can extract the parameters from the args dictionary and configure your settings
+ let fps = args["fps"] as? Int
+ let outputs = OutputFormatSetting(args["outputs"] as? String ?? "")
+ let backend = URL(string: args["backend"] as? String ?? "")
+ let backendOutput = OutputFormatSetting(args["backend_output"] as? String ?? "")
+ let keepLocalFiles = args["keep_local_files"] as? Bool
+
+ let config = ConfigureAction(
+ action: "configure",
+ fps: fps,
+ outputs: outputs,
+ backend: backend,
+ backendOutput: backendOutput,
+ keepLocalFiles: keepLocalFiles
+ )
+
+ NotificationCenter.default.post(name: .setConfiguration, object: nil, userInfo: [
+ "config": config
+ ])
+ NotificationCenter.default.post(name: .reloadConfiguration, object: nil, userInfo: nil)
+
+ // Return a result if needed
+ return nil
+ }
+}