Skip to content

Commit

Permalink
added HotKey
Browse files Browse the repository at this point in the history
Cmd+Opt+G
  • Loading branch information
artginzburg committed Jan 28, 2020
1 parent 0d9bd88 commit b2bda09
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
25 changes: 21 additions & 4 deletions 2FA to Tray.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand All @@ -33,6 +34,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
313F4DB523E00DC40086E836 /* HotKey in Frameworks */,
3152B18723DF762300B8FA7E /* KeychainAccess in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -89,6 +91,7 @@
name = "2FA to Tray";
packageProductDependencies = (
3152B18623DF762300B8FA7E /* KeychainAccess */,
313F4DB423E00DC40086E836 /* HotKey */,
);
productName = "2FA to Tray";
productReference = 3148B57523DE260D0075A192 /* 2FA to Tray.app */;
Expand Down Expand Up @@ -120,6 +123,7 @@
mainGroup = 3148B56C23DE260D0075A192;
packageReferences = (
3152B18523DF762300B8FA7E /* XCRemoteSwiftPackageReference "KeychainAccess" */,
313F4DB323E00DC40086E836 /* XCRemoteSwiftPackageReference "HotKey" */,
);
productRefGroup = 3148B57623DE260D0075A192 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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";
Expand All @@ -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" */;
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
15 changes: 15 additions & 0 deletions 2FA to Tray/StatusMenuController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -97,6 +107,11 @@ class StatusMenuController: NSObject, NSMenuDelegate {
}

button.addSubview(mouseView)

let hotKey = HotKey(key: .g, modifiers: [.command, .option])
hotKey.handleKeyDown {
otp.copy()
}
}
}

Expand Down

0 comments on commit b2bda09

Please sign in to comment.