-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added SketchyBar integration (#10)
Resolves #2
- Loading branch information
1 parent
e7fa1f1
commit dc1f9cc
Showing
7 changed files
with
186 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// IntegrationsSettingsView.swift | ||
// | ||
// Created by Wojciech Kulik on 24/01/2025. | ||
// Copyright © 2025 Wojciech Kulik. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct IntegrationsSettingsView: View { | ||
@StateObject var settings = AppDependencies.shared.settingsRepository | ||
|
||
var body: some View { | ||
Form { | ||
Section { | ||
Toggle("Enable integrations", isOn: $settings.enableIntegrations) | ||
} | ||
|
||
Section( | ||
header: Text("Run script on workspace change:"), | ||
footer: Text( | ||
""" | ||
$WORKSPACE will be replaced with the active workspace name | ||
$DISPLAY will be replaced with the corresponding display name | ||
""" | ||
) | ||
.foregroundStyle(.secondary) | ||
) { | ||
TextField("", text: $settings.runScriptOnWorkspaceChange) | ||
} | ||
} | ||
.formStyle(.grouped) | ||
.navigationTitle("Integrations") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// Integrations.swift | ||
// | ||
// Created by Wojciech Kulik on 24/01/2025. | ||
// Copyright © 2025 Wojciech Kulik. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
enum Integrations { | ||
private static let settings = AppDependencies.shared.settingsRepository | ||
|
||
static func runIfNeeded(workspace: Workspace) { | ||
let script = settings.runScriptOnWorkspaceChange.trimmingCharacters(in: .whitespaces) | ||
|
||
guard settings.enableIntegrations, !script.isEmpty else { return } | ||
|
||
let scriptWithReplacements = script | ||
.replacingOccurrences(of: "$WORKSPACE", with: workspace.name) | ||
.replacingOccurrences(of: "$DISPLAY", with: workspace.display) | ||
|
||
let task = Process() | ||
task.launchPath = "/bin/bash" | ||
task.arguments = ["-c", scriptWithReplacements] | ||
task.launch() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters