diff --git a/2FA to Tray.xcodeproj/project.pbxproj b/2FA to Tray.xcodeproj/project.pbxproj index a3c2306..73f2b7a 100644 --- a/2FA to Tray.xcodeproj/project.pbxproj +++ b/2FA to Tray.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 313F4DB523E00DC40086E836 /* HotKey in Frameworks */ = {isa = PBXBuildFile; productRef = 313F4DB423E00DC40086E836 /* HotKey */; }; 3148B57923DE260D0075A192 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3148B57823DE260D0075A192 /* AppDelegate.swift */; }; 3148B57B23DE260F0075A192 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3148B57A23DE260F0075A192 /* Assets.xcassets */; }; 3148B57E23DE260F0075A192 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3148B57C23DE260F0075A192 /* MainMenu.xib */; }; @@ -33,6 +34,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 313F4DB523E00DC40086E836 /* HotKey in Frameworks */, 3152B18723DF762300B8FA7E /* KeychainAccess in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -89,6 +91,7 @@ name = "2FA to Tray"; packageProductDependencies = ( 3152B18623DF762300B8FA7E /* KeychainAccess */, + 313F4DB423E00DC40086E836 /* HotKey */, ); productName = "2FA to Tray"; productReference = 3148B57523DE260D0075A192 /* 2FA to Tray.app */; @@ -120,6 +123,7 @@ mainGroup = 3148B56C23DE260D0075A192; packageReferences = ( 3152B18523DF762300B8FA7E /* XCRemoteSwiftPackageReference "KeychainAccess" */, + 313F4DB323E00DC40086E836 /* XCRemoteSwiftPackageReference "HotKey" */, ); productRefGroup = 3148B57623DE260D0075A192 /* Products */; projectDirPath = ""; @@ -289,14 +293,14 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 3; + CURRENT_PROJECT_VERSION = 4; DEVELOPMENT_TEAM = R2294BC6J8; INFOPLIST_FILE = "2FA to Tray/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = 1.2; + MARKETING_VERSION = 1.2.1; PRODUCT_BUNDLE_IDENTIFIER = com.dafuqtor.2FAtoTray; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -311,14 +315,14 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 3; + CURRENT_PROJECT_VERSION = 4; DEVELOPMENT_TEAM = R2294BC6J8; INFOPLIST_FILE = "2FA to Tray/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = 1.2; + MARKETING_VERSION = 1.2.1; PRODUCT_BUNDLE_IDENTIFIER = com.dafuqtor.2FAtoTray; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -349,6 +353,14 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ + 313F4DB323E00DC40086E836 /* XCRemoteSwiftPackageReference "HotKey" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/soffes/HotKey"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 0.1.3; + }; + }; 3152B18523DF762300B8FA7E /* XCRemoteSwiftPackageReference "KeychainAccess" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/kishikawakatsumi/KeychainAccess.git"; @@ -360,6 +372,11 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ + 313F4DB423E00DC40086E836 /* HotKey */ = { + isa = XCSwiftPackageProductDependency; + package = 313F4DB323E00DC40086E836 /* XCRemoteSwiftPackageReference "HotKey" */; + productName = HotKey; + }; 3152B18623DF762300B8FA7E /* KeychainAccess */ = { isa = XCSwiftPackageProductDependency; package = 3152B18523DF762300B8FA7E /* XCRemoteSwiftPackageReference "KeychainAccess" */; diff --git a/2FA to Tray.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/2FA to Tray.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index a5b1e14..e654a86 100644 --- a/2FA to Tray.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/2FA to Tray.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,6 +1,15 @@ { "object": { "pins": [ + { + "package": "HotKey", + "repositoryURL": "https://github.com/soffes/HotKey", + "state": { + "branch": null, + "revision": "c13662730cb5bc28de4a799854bbb018a90649bf", + "version": "0.1.3" + } + }, { "package": "KeychainAccess", "repositoryURL": "https://github.com/kishikawakatsumi/KeychainAccess.git", diff --git a/2FA to Tray/StatusMenuController.swift b/2FA to Tray/StatusMenuController.swift index c07b5d8..eba73b1 100644 --- a/2FA to Tray/StatusMenuController.swift +++ b/2FA to Tray/StatusMenuController.swift @@ -7,11 +7,21 @@ // import Cocoa +import HotKey let otp = OTP() let statusItem = NSStatusBar.system.statusItem(withLength: 22) +private extension HotKey { + func handleKeyDown(_ handler: @escaping (() -> Void)) { + keyDownHandler = { + handler() + self.handleKeyDown(handler) + } + } +} + class StatusMenuController: NSObject, NSMenuDelegate { func resize(image: NSImage, w: Int, h: Int) -> NSImage { @@ -97,6 +107,11 @@ class StatusMenuController: NSObject, NSMenuDelegate { } button.addSubview(mouseView) + + let hotKey = HotKey(key: .g, modifiers: [.command, .option]) + hotKey.handleKeyDown { + otp.copy() + } } }