Skip to content

Commit

Permalink
Merge branch 'feature' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ruittenb committed Dec 30, 2024
2 parents a1a095e + 0f8fe82 commit c3aca92
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
8 changes: 4 additions & 4 deletions Spaceman.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.6.18;
CURRENT_PROJECT_VERSION = 1.6.19;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Spaceman/Preview Content\"";
DEVELOPMENT_TEAM = "";
Expand All @@ -480,7 +480,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.6.18;
MARKETING_VERSION = 1.6.19;
PRODUCT_BUNDLE_IDENTIFIER = dev.ruittenb.Spaceman;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -499,7 +499,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.6.18;
CURRENT_PROJECT_VERSION = 1.6.19;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Spaceman/Preview Content\"";
DEVELOPMENT_TEAM = "";
Expand All @@ -514,7 +514,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.6.18;
MARKETING_VERSION = 1.6.19;
PRODUCT_BUNDLE_IDENTIFIER = dev.ruittenb.Spaceman;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
14 changes: 9 additions & 5 deletions Spaceman/Helpers/SpaceSwitcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ class SpaceSwitcher {
if let scriptObject = NSAppleScript(source: appleScript) {
scriptObject.executeAndReturnError(&error)
if error != nil {
let errorNumber: Int = error?[NSAppleScript.errorNumber] as! Int
let errorBriefMessage: String = error?[NSAppleScript.errorBriefMessage] as! String
let settingsName = self.systemSettingsName()
// -1002: Error: Spaceman is not allowed to send keystrokes. (needs Accessibility permission)
// -1743: Error: Not authorized to send Apple events to System Events. (needs Automation permission)
let permissionType = errorNumber == 1002 ? "Accessibility" : "Automation"
self.alert(
msg: "Error: \(errorBriefMessage)\n\nPlease grant Accessibility permissions to Spaceman in \(settingsName) → Privacy and Security.",
withSettingsButton: true)
msg: "Error: \(errorBriefMessage)\n\nPlease grant \(permissionType) permissions to Spaceman in \(settingsName) → Privacy and Security.",
permissionTypeName: permissionType)
}
}
}
Expand All @@ -56,21 +60,21 @@ class SpaceSwitcher {
}
}

private func alert(msg: String, withSettingsButton: Bool) {
private func alert(msg: String, permissionTypeName: String) {
DispatchQueue.main.async {
let alert = NSAlert.init()
alert.messageText = "Spaceman"
alert.informativeText = "\(msg)"
alert.addButton(withTitle: "Dismiss")
if withSettingsButton {
if permissionTypeName != "" {
let settingsName = self.systemSettingsName()
alert.addButton(withTitle: "\(settingsName)...")
}
let response = alert.runModal()
if (response == .alertSecondButtonReturn) {
let task = Process()
task.launchPath = "/usr/bin/open"
task.arguments = ["x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"]
task.arguments = ["x-apple.systempreferences:com.apple.preference.security?Privacy_\(permissionTypeName)"]
try? task.run()
}
}
Expand Down
2 changes: 2 additions & 0 deletions Spaceman/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppleEventsUsageDescription</key>
<string>This app uses AppleScript to switch desktops</string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
Expand Down
Binary file added publicity/yabai-spaceman-kaders.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c3aca92

Please sign in to comment.