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
17 changes: 0 additions & 17 deletions .github/workflows/appcast.yml

This file was deleted.

55 changes: 55 additions & 0 deletions Leader Key.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
427C18502BD6652500955B98 /* Util.swift in Sources */ = {isa = PBXBuildFile; fileRef = 427C184F2BD6652500955B98 /* Util.swift */; };
427C18542BD6E59300955B98 /* NSWindow+Animations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 427C18532BD6E59300955B98 /* NSWindow+Animations.swift */; };
4284834C2E813212009D7EEF /* KeyboardLayoutTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4284834B2E813212009D7EEF /* KeyboardLayoutTests.swift */; };
6A9D3E8101A24B6300D4C101 /* RightCommandMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A9D3E8001A24B6300D4C101 /* RightCommandMonitor.swift */; };
6A9D3E8301A24B6300D4C101 /* RightCommandMonitorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A9D3E8201A24B6300D4C101 /* RightCommandMonitorTests.swift */; };
42B21FBC2D67566100F4A2C7 /* Alerts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42B21FBB2D67566100F4A2C7 /* Alerts.swift */; };
42CCB5A32DAD257700356FC0 /* Kingfisher in Frameworks */ = {isa = PBXBuildFile; productRef = FBCA04D82D9F02F700271163 /* Kingfisher */; };
42DFCD722D5B7D48002EA111 /* Events.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42DFCD712D5B7D46002EA111 /* Events.swift */; };
Expand Down Expand Up @@ -102,6 +104,8 @@
427C184F2BD6652500955B98 /* Util.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Util.swift; sourceTree = "<group>"; };
427C18532BD6E59300955B98 /* NSWindow+Animations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSWindow+Animations.swift"; sourceTree = "<group>"; };
4284834B2E813212009D7EEF /* KeyboardLayoutTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyboardLayoutTests.swift; sourceTree = "<group>"; };
6A9D3E8001A24B6300D4C101 /* RightCommandMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RightCommandMonitor.swift; sourceTree = "<group>"; };
6A9D3E8201A24B6300D4C101 /* RightCommandMonitorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RightCommandMonitorTests.swift; sourceTree = "<group>"; };
42B21FBB2D67566100F4A2C7 /* Alerts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Alerts.swift; sourceTree = "<group>"; };
42DFCD712D5B7D46002EA111 /* Events.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Events.swift; sourceTree = "<group>"; };
42F4CDC82D458FF700D0DD76 /* MainMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenu.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -193,6 +197,7 @@
427C181B2BD314B500955B98 /* Constants.swift */,
427C18272BD31E2E00955B98 /* Controller.swift */,
427C184C2BD65C5C00955B98 /* Defaults.swift */,
6A9D3E8001A24B6300D4C101 /* RightCommandMonitor.swift */,
42DFCD712D5B7D46002EA111 /* Events.swift */,
42F4CDD02D48C51F00D0DD76 /* Extensions.swift */,
42F4CDC82D458FF700D0DD76 /* MainMenu.swift */,
Expand Down Expand Up @@ -228,6 +233,7 @@
42454DDC2D71CBAB004E1374 /* ConfigValidatorTests.swift */,
EC5CEBC4C47B4C5DB2258814 /* URLSchemeTests.swift */,
427C17FC2BD311B500955B98 /* UserConfigTests.swift */,
6A9D3E8201A24B6300D4C101 /* RightCommandMonitorTests.swift */,
);
path = "Leader KeyTests";
sourceTree = "<group>";
Expand Down Expand Up @@ -415,6 +421,7 @@
42F4CDC92D458FF700D0DD76 /* MainMenu.swift in Sources */,
42454DDB2D71CB39004E1374 /* ConfigValidator.swift in Sources */,
427C184D2BD65C5C00955B98 /* Defaults.swift in Sources */,
6A9D3E8101A24B6300D4C101 /* RightCommandMonitor.swift in Sources */,
427C18292BD31E2E00955B98 /* MainWindow.swift in Sources */,
42FDC31A2D51687B004F5C5C /* AdvancedPane.swift in Sources */,
115AA5BF2DA521C600C17E18 /* ActionIcon.swift in Sources */,
Expand Down Expand Up @@ -454,6 +461,7 @@
EC5CEBC4C47B4C5DB2258813 /* URLSchemeTests.swift in Sources */,
427C17FD2BD311B500955B98 /* UserConfigTests.swift in Sources */,
4284834C2E813212009D7EEF /* KeyboardLayoutTests.swift in Sources */,
6A9D3E8301A24B6300D4C101 /* RightCommandMonitorTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -596,6 +604,15 @@
};
name = Release;
};
A1B2C3D42C3D4E5F00112233 /* Beta */ = {
isa = XCBuildConfiguration;
buildSettings = {
MACOSX_DEPLOYMENT_TARGET = 14.4;
SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "BETA $(inherited)";
};
name = Beta;
};
427C180D2BD311B500955B98 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
Expand Down Expand Up @@ -668,6 +685,42 @@
};
name = Release;
};
A1B2C3D52C3D4E5F00112233 /* Beta */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CODE_SIGN_ENTITLEMENTS = "Leader Key/Leader_Key.entitlements";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 155;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Leader Key/Support/Preview Content\"";
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "Leader Key/Support/Beta-Info.plist";
INFOPLIST_KEY_CFBundleDisplayName = "Leader Key Beta";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
INFOPLIST_KEY_LSUIElement = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
INFOPLIST_KEY_NSMainStoryboardFile = Main;
INFOPLIST_KEY_NSPrincipalClass = NSApplication;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.17.3;
PRODUCT_BUNDLE_IDENTIFIER = "com.brnbw.Leader-Key.beta";
PRODUCT_NAME = "Leader Key Beta";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
};
name = Beta;
};
427C18102BD311B500955B98 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
Expand Down Expand Up @@ -712,6 +765,7 @@
buildConfigurations = (
427C180A2BD311B500955B98 /* Debug */,
427C180B2BD311B500955B98 /* Release */,
A1B2C3D42C3D4E5F00112233 /* Beta */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
Expand All @@ -721,6 +775,7 @@
buildConfigurations = (
427C180D2BD311B500955B98 /* Debug */,
427C180E2BD311B500955B98 /* Release */,
A1B2C3D52C3D4E5F00112233 /* Beta */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2600"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "NO"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "427C17E62BD311B400955B98"
BuildableName = "Leader Key Beta.app"
BlueprintName = "Leader Key"
ReferencedContainer = "container:Leader Key.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES" />
<LaunchAction
buildConfiguration = "Beta"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "427C17E62BD311B400955B98"
BuildableName = "Leader Key Beta.app"
BlueprintName = "Leader Key"
ReferencedContainer = "container:Leader Key.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Beta"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES" />
<AnalyzeAction
buildConfiguration = "Beta" />
<ArchiveAction
buildConfiguration = "Beta"
revealArchiveInOrganizer = "YES" />
</Scheme>
38 changes: 33 additions & 5 deletions Leader Key/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class AppDelegate: NSObject, NSApplicationDelegate,

let statusItem = StatusItem()
let config = UserConfig()
lazy var rightCommandMonitor = RightCommandMonitor { [weak self] in
self?.activate()
}

var state: UserState!
@IBOutlet var updaterController: SPUStandardUpdaterController!
Expand Down Expand Up @@ -66,9 +69,11 @@ class AppDelegate: NSObject, NSApplicationDelegate,
statusItem.handleRevealConfig = {
NSWorkspace.shared.activateFileViewerSelecting([self.config.url])
}
statusItem.handleCheckForUpdates = {
self.updaterController.checkForUpdates(nil)
}
#if !BETA
statusItem.handleCheckForUpdates = {
self.updaterController.checkForUpdates(nil)
}
#endif

Task {
for await value in Defaults.updates(.showMenuBarIcon) {
Expand All @@ -90,6 +95,13 @@ class AppDelegate: NSObject, NSApplicationDelegate,
// Activation policy is managed solely by the Settings window

registerGlobalShortcuts()
updateRightCommandMonitor(enabled: Defaults[.useRightCommandAsLeader])

Task { @MainActor in
for await enabled in Defaults.updates(.useRightCommandAsLeader) {
self.updateRightCommandMonitor(enabled: enabled)
}
}
}

func activate() {
Expand Down Expand Up @@ -126,13 +138,29 @@ class AppDelegate: NSObject, NSApplicationDelegate,
self.processKeys([groupKey])
}
}
if Defaults[.groupShortcuts].isEmpty && !KeyboardShortcuts.isEnabled(for: .activate) {
let hasRightCommandShortcut =
Defaults[.useRightCommandAsLeader] && rightCommandMonitor.hasInputMonitoringPermission
if Defaults[.groupShortcuts].isEmpty && !KeyboardShortcuts.isEnabled(for: .activate)
&& !hasRightCommandShortcut
{
showSettings()
}
}

private func updateRightCommandMonitor(enabled: Bool) {
if enabled && rightCommandMonitor.hasInputMonitoringPermission {
rightCommandMonitor.start()
} else {
rightCommandMonitor.stop()
}
}

func refreshRightCommandMonitor() {
updateRightCommandMonitor(enabled: Defaults[.useRightCommandAsLeader])
}

func applicationWillTerminate(_ notification: Notification) {
// Config saves automatically on changes
rightCommandMonitor.stop()
}

@IBAction
Expand Down
2 changes: 2 additions & 0 deletions Leader Key/Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ extension Defaults.Keys {
static let groupShortcuts = Key<Set<String>>(
"groupShortcuts",
default: Set(), suite: defaultsSuite)
static let useRightCommandAsLeader = Key<Bool>(
"useRightCommandAsLeader", default: false, suite: defaultsSuite)
}

enum AutoOpenCheatsheetSetting: String, Defaults.Serializable {
Expand Down
Loading