Skip to content

Commit c3aca92

Browse files
committed
Merge branch 'feature' into main
2 parents a1a095e + 0f8fe82 commit c3aca92

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

Spaceman.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@
465465
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
466466
CODE_SIGN_STYLE = Manual;
467467
COMBINE_HIDPI_IMAGES = YES;
468-
CURRENT_PROJECT_VERSION = 1.6.18;
468+
CURRENT_PROJECT_VERSION = 1.6.19;
469469
DEAD_CODE_STRIPPING = YES;
470470
DEVELOPMENT_ASSET_PATHS = "\"Spaceman/Preview Content\"";
471471
DEVELOPMENT_TEAM = "";
@@ -480,7 +480,7 @@
480480
"@executable_path/../Frameworks",
481481
);
482482
MACOSX_DEPLOYMENT_TARGET = 11.0;
483-
MARKETING_VERSION = 1.6.18;
483+
MARKETING_VERSION = 1.6.19;
484484
PRODUCT_BUNDLE_IDENTIFIER = dev.ruittenb.Spaceman;
485485
PRODUCT_NAME = "$(TARGET_NAME)";
486486
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -499,7 +499,7 @@
499499
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
500500
CODE_SIGN_STYLE = Manual;
501501
COMBINE_HIDPI_IMAGES = YES;
502-
CURRENT_PROJECT_VERSION = 1.6.18;
502+
CURRENT_PROJECT_VERSION = 1.6.19;
503503
DEAD_CODE_STRIPPING = YES;
504504
DEVELOPMENT_ASSET_PATHS = "\"Spaceman/Preview Content\"";
505505
DEVELOPMENT_TEAM = "";
@@ -514,7 +514,7 @@
514514
"@executable_path/../Frameworks",
515515
);
516516
MACOSX_DEPLOYMENT_TARGET = 11.0;
517-
MARKETING_VERSION = 1.6.18;
517+
MARKETING_VERSION = 1.6.19;
518518
PRODUCT_BUNDLE_IDENTIFIER = dev.ruittenb.Spaceman;
519519
PRODUCT_NAME = "$(TARGET_NAME)";
520520
PROVISIONING_PROFILE_SPECIFIER = "";

Spaceman/Helpers/SpaceSwitcher.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@ class SpaceSwitcher {
2727
if let scriptObject = NSAppleScript(source: appleScript) {
2828
scriptObject.executeAndReturnError(&error)
2929
if error != nil {
30+
let errorNumber: Int = error?[NSAppleScript.errorNumber] as! Int
3031
let errorBriefMessage: String = error?[NSAppleScript.errorBriefMessage] as! String
3132
let settingsName = self.systemSettingsName()
33+
// -1002: Error: Spaceman is not allowed to send keystrokes. (needs Accessibility permission)
34+
// -1743: Error: Not authorized to send Apple events to System Events. (needs Automation permission)
35+
let permissionType = errorNumber == 1002 ? "Accessibility" : "Automation"
3236
self.alert(
33-
msg: "Error: \(errorBriefMessage)\n\nPlease grant Accessibility permissions to Spaceman in \(settingsName) → Privacy and Security.",
34-
withSettingsButton: true)
37+
msg: "Error: \(errorBriefMessage)\n\nPlease grant \(permissionType) permissions to Spaceman in \(settingsName) → Privacy and Security.",
38+
permissionTypeName: permissionType)
3539
}
3640
}
3741
}
@@ -56,21 +60,21 @@ class SpaceSwitcher {
5660
}
5761
}
5862

59-
private func alert(msg: String, withSettingsButton: Bool) {
63+
private func alert(msg: String, permissionTypeName: String) {
6064
DispatchQueue.main.async {
6165
let alert = NSAlert.init()
6266
alert.messageText = "Spaceman"
6367
alert.informativeText = "\(msg)"
6468
alert.addButton(withTitle: "Dismiss")
65-
if withSettingsButton {
69+
if permissionTypeName != "" {
6670
let settingsName = self.systemSettingsName()
6771
alert.addButton(withTitle: "\(settingsName)...")
6872
}
6973
let response = alert.runModal()
7074
if (response == .alertSecondButtonReturn) {
7175
let task = Process()
7276
task.launchPath = "/usr/bin/open"
73-
task.arguments = ["x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"]
77+
task.arguments = ["x-apple.systempreferences:com.apple.preference.security?Privacy_\(permissionTypeName)"]
7478
try? task.run()
7579
}
7680
}

Spaceman/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>NSAppleEventsUsageDescription</key>
6+
<string>This app uses AppleScript to switch desktops</string>
57
<key>CFBundleDevelopmentRegion</key>
68
<string>$(DEVELOPMENT_LANGUAGE)</string>
79
<key>CFBundleDisplayName</key>

publicity/yabai-spaceman-kaders.png

9.28 KB
Loading

0 commit comments

Comments
 (0)