diff options
author | Teddy Wing | 2016-12-01 13:36:32 -0500 |
---|---|---|
committer | Teddy Wing | 2016-12-01 13:36:32 -0500 |
commit | 22e657a042d653e5abcdb876d843bb80343e9053 (patch) | |
tree | 10623c631114b9be22d9a3de81054230cdb8b138 | |
parent | 9984853a24eb148742e5e60c8b9ad4961ad399c3 (diff) | |
download | Low-Battery-Yup-22e657a042d653e5abcdb876d843bb80343e9053.tar.bz2 |
Make click work from hotkey in NSUserDefaults
Get the shortcut saved from the windows application in our daemon and if
there is one, use that as the hotkey to activate the mouse click.
Yay! This is coming together!
-rw-r--r-- | Low Battery Yup d/AppDelegate.m | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/Low Battery Yup d/AppDelegate.m b/Low Battery Yup d/AppDelegate.m index 7aa29fe..c47df18 100644 --- a/Low Battery Yup d/AppDelegate.m +++ b/Low Battery Yup d/AppDelegate.m @@ -9,6 +9,7 @@ #import "AppDelegate.h" #import "DDHotKeyCenter.h" #import <Carbon/Carbon.h> +#import "Constants.h" @implementation AppDelegate @@ -22,12 +23,17 @@ { _mouse = [[Mouse alloc] init]; - DDHotKeyCenter *hotkey_center = [DDHotKeyCenter sharedHotKeyCenter]; - [hotkey_center registerHotKeyWithKeyCode:kVK_ANSI_0 - modifierFlags:(NSCommandKeyMask | NSAlternateKeyMask | NSShiftKeyMask | NSControlKeyMask) - target:self - action:@selector(dismissLowBatteryWarning:) - object:nil]; + [[NSUserDefaults standardUserDefaults] addSuiteNamed:@"com.teddywing.Low-Battery-Yup"]; + NSDictionary *shortcut = [[NSUserDefaults standardUserDefaults] objectForKey:kPreferenceGlobalShortcut]; + + if (shortcut) { + DDHotKeyCenter *hotkey_center = [DDHotKeyCenter sharedHotKeyCenter]; + [hotkey_center registerHotKeyWithKeyCode:[[shortcut objectForKey:@"keyCode"] unsignedIntegerValue] + modifierFlags:[[shortcut objectForKey:@"modifierFlags"] unsignedIntegerValue] + target:self + action:@selector(dismissLowBatteryWarning:) + object:nil]; + } } - (void)dismissLowBatteryWarning:(NSEvent *)hotKeyEvent |