Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion StikJIT/JSSupport/RunJSView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,15 @@ class RunJSViewModel: ObservableObject {
if let exception = self.context?.exception {
self.logs.append(exception.debugDescription)
}

self.logs.append("Script Execution Completed")
self.logs.append("You are safe to close the PIP Window.")

if UserDefaults.standard.bool(forKey: "closeAfterScript") {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
exit(0)
}
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions StikJIT/Views/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct HomeView: View {

@AppStorage("useDefaultScript") private var useDefaultScript = false
@AppStorage("enablePiP") private var enablePiP = true
@AppStorage("closeAfterScript") private var closeAfterScript = false
@State var scriptViewShow = false
@AppStorage("DefaultScriptName") var selectedScript = "attachDetach.js"
@State var jsModel: RunJSViewModel?
Expand Down
5 changes: 5 additions & 0 deletions StikJIT/Views/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct SettingsView: View {
@AppStorage("useDefaultScript") private var useDefaultScript = false
@AppStorage("enableAdvancedOptions") private var enableAdvancedOptions = false
@AppStorage("enablePiP") private var enablePiP = true
@AppStorage("closeAfterScript") private var closeAfterScript = false

@State private var isShowingPairingFilePicker = false
@Environment(\.colorScheme) private var colorScheme
Expand Down Expand Up @@ -284,6 +285,9 @@ struct SettingsView: View {
Toggle("Picture in Picture", isOn: $enablePiP)
.foregroundColor(.primary)
.padding(.vertical, 6)
Toggle("Close App After Running Script", isOn: $closeAfterScript)
.foregroundColor(.primary)
.padding(.vertical, 6)
}
}
.padding(.vertical, 20)
Expand All @@ -292,6 +296,7 @@ struct SettingsView: View {
if !newValue {
useDefaultScript = false
enablePiP = false
closeAfterScript = false
}
}
}
Expand Down