aboutsummaryrefslogtreecommitdiff
path: root/Captura/Scripting
diff options
context:
space:
mode:
authorRuben Beltran del Rio <ruben@unlimited.pizza>2023-08-02 22:23:48 +0200
committerRuben Beltran del Rio <ruben@unlimited.pizza>2023-08-02 22:23:48 +0200
commite42019cd38b59e757f6036b132614a471d4cf6fe (patch)
tree2c95f67640d01a63ef9696ec23d429b866d87293 /Captura/Scripting
parent153f3309127a4f9d898310224a467d11eef0f2ff (diff)
Adds configure support for URLs
Diffstat (limited to 'Captura/Scripting')
-rw-r--r--Captura/Scripting/Captura.sdef14
-rw-r--r--Captura/Scripting/ConfigureCommand.swift33
2 files changed, 41 insertions, 6 deletions
diff --git a/Captura/Scripting/Captura.sdef b/Captura/Scripting/Captura.sdef
index ca49d17..0ad7f55 100644
--- a/Captura/Scripting/Captura.sdef
+++ b/Captura/Scripting/Captura.sdef
@@ -8,18 +8,14 @@
<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." />
@@ -41,5 +37,11 @@
<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>
diff --git a/Captura/Scripting/ConfigureCommand.swift b/Captura/Scripting/ConfigureCommand.swift
new file mode 100644
index 0000000..4e42326
--- /dev/null
+++ b/Captura/Scripting/ConfigureCommand.swift
@@ -0,0 +1,33 @@
+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
+ }
+}