Skip to content

Commit

Permalink
Added hotkey support (hardcoded to Shift-Cmd-L)
Browse files Browse the repository at this point in the history
  • Loading branch information
pajp committed Jul 16, 2014
1 parent 2e9642a commit 706ef54
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "DDHotKey"]
path = DDHotKey
url = [email protected]:davedelong/DDHotKey.git
1 change: 1 addition & 0 deletions DDHotKey
Submodule DDHotKey added at 6e52b1
28 changes: 28 additions & 0 deletions Lampster.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
3A02CBCD1975BFCB006F405C /* RHSLIFXClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A02CBCC1975BFCB006F405C /* RHSLIFXClient.m */; };
3A02CBCF1975C35E006F405C /* lifxclient.rb in Resources */ = {isa = PBXBuildFile; fileRef = 3A02CBCE1975C35E006F405C /* lifxclient.rb */; };
3A02CBD21975CC5C006F405C /* DDFileReader.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A02CBD11975CC5C006F405C /* DDFileReader.m */; };
3A02CBDC1976F988006F405C /* DDHotKeyAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A02CBD51976F988006F405C /* DDHotKeyAppDelegate.m */; };
3A02CBDD1976F988006F405C /* DDHotKeyCenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A02CBD71976F988006F405C /* DDHotKeyCenter.m */; };
3A02CBDE1976F988006F405C /* DDHotKeyTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A02CBD91976F988006F405C /* DDHotKeyTextField.m */; };
3A02CBDF1976F988006F405C /* DDHotKeyUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A02CBDB1976F988006F405C /* DDHotKeyUtilities.m */; };
3A02CBE11976F997006F405C /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A02CBE01976F997006F405C /* Carbon.framework */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -58,13 +63,23 @@
3A02CBCE1975C35E006F405C /* lifxclient.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = lifxclient.rb; sourceTree = "<group>"; };
3A02CBD01975CC5C006F405C /* DDFileReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDFileReader.h; sourceTree = "<group>"; };
3A02CBD11975CC5C006F405C /* DDFileReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDFileReader.m; sourceTree = "<group>"; };
3A02CBD41976F988006F405C /* DDHotKeyAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DDHotKeyAppDelegate.h; path = DDHotKey/DDHotKeyAppDelegate.h; sourceTree = SOURCE_ROOT; };
3A02CBD51976F988006F405C /* DDHotKeyAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DDHotKeyAppDelegate.m; path = DDHotKey/DDHotKeyAppDelegate.m; sourceTree = SOURCE_ROOT; };
3A02CBD61976F988006F405C /* DDHotKeyCenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DDHotKeyCenter.h; path = DDHotKey/DDHotKeyCenter.h; sourceTree = SOURCE_ROOT; };
3A02CBD71976F988006F405C /* DDHotKeyCenter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DDHotKeyCenter.m; path = DDHotKey/DDHotKeyCenter.m; sourceTree = SOURCE_ROOT; };
3A02CBD81976F988006F405C /* DDHotKeyTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DDHotKeyTextField.h; path = DDHotKey/DDHotKeyTextField.h; sourceTree = SOURCE_ROOT; };
3A02CBD91976F988006F405C /* DDHotKeyTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DDHotKeyTextField.m; path = DDHotKey/DDHotKeyTextField.m; sourceTree = SOURCE_ROOT; };
3A02CBDA1976F988006F405C /* DDHotKeyUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DDHotKeyUtilities.h; path = DDHotKey/DDHotKeyUtilities.h; sourceTree = SOURCE_ROOT; };
3A02CBDB1976F988006F405C /* DDHotKeyUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DDHotKeyUtilities.m; path = DDHotKey/DDHotKeyUtilities.m; sourceTree = SOURCE_ROOT; };
3A02CBE01976F997006F405C /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
3A02CB911975BF24006F405C /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
3A02CBE11976F997006F405C /* Carbon.framework in Frameworks */,
3A02CB981975BF25006F405C /* Cocoa.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -103,6 +118,7 @@
3A02CB961975BF25006F405C /* Frameworks */ = {
isa = PBXGroup;
children = (
3A02CBE01976F997006F405C /* Carbon.framework */,
3A02CB971975BF25006F405C /* Cocoa.framework */,
3A02CBB61975BF25006F405C /* XCTest.framework */,
3A02CB991975BF25006F405C /* Other Frameworks */,
Expand Down Expand Up @@ -132,6 +148,14 @@
3A02CBD11975CC5C006F405C /* DDFileReader.m */,
3A02CBCE1975C35E006F405C /* lifxclient.rb */,
3A02CBAF1975BF25006F405C /* Images.xcassets */,
3A02CBD41976F988006F405C /* DDHotKeyAppDelegate.h */,
3A02CBD51976F988006F405C /* DDHotKeyAppDelegate.m */,
3A02CBD61976F988006F405C /* DDHotKeyCenter.h */,
3A02CBD71976F988006F405C /* DDHotKeyCenter.m */,
3A02CBD81976F988006F405C /* DDHotKeyTextField.h */,
3A02CBD91976F988006F405C /* DDHotKeyTextField.m */,
3A02CBDA1976F988006F405C /* DDHotKeyUtilities.h */,
3A02CBDB1976F988006F405C /* DDHotKeyUtilities.m */,
3A02CB9E1975BF25006F405C /* Supporting Files */,
);
path = Lampster;
Expand Down Expand Up @@ -289,7 +313,11 @@
files = (
3A02CBD21975CC5C006F405C /* DDFileReader.m in Sources */,
3A02CBCD1975BFCB006F405C /* RHSLIFXClient.m in Sources */,
3A02CBDC1976F988006F405C /* DDHotKeyAppDelegate.m in Sources */,
3A02CBDE1976F988006F405C /* DDHotKeyTextField.m in Sources */,
3A02CBAB1975BF25006F405C /* RHSAppDelegate.m in Sources */,
3A02CBDD1976F988006F405C /* DDHotKeyCenter.m in Sources */,
3A02CBDF1976F988006F405C /* DDHotKeyUtilities.m in Sources */,
3A02CBA41975BF25006F405C /* main.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
3 changes: 1 addition & 2 deletions Lampster/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@
</menu>
<window title="Lampster" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" appearanceType="lightContent" animationBehavior="default" id="QvC-M9-y7g">
<windowStyleMask key="styleMask" titled="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="335" y="390" width="87" height="134"/>
<rect key="contentRect" x="843" y="437" width="87" height="134"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1028"/>
<view key="contentView" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="87" height="134"/>
Expand Down
2 changes: 1 addition & 1 deletion Lampster/RHSAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import <Cocoa/Cocoa.h>
#import "RHSLIFXClient.h"

#import "DDHotKeyCenter.h"
@interface RHSAppDelegate : NSObject <NSApplicationDelegate>
@property (weak) IBOutlet NSButton *onButton;
@property (weak) IBOutlet NSButton *offButton;
Expand Down
5 changes: 5 additions & 0 deletions Lampster/RHSAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ @implementation RHSAppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
DDHotKeyCenter* hkc = [DDHotKeyCenter sharedHotKeyCenter];
[hkc registerHotKey:[DDHotKey hotKeyWithKeyCode:37 modifierFlags:NSShiftKeyMask|NSCommandKeyMask task:^(NSEvent *event) {
NSLog(@"Got hot key event! %@", event);
[NSApp activateIgnoringOtherApps:YES];
}]];
self.lifxClient = [RHSLIFXClient new];
__weak RHSAppDelegate* _self = self;
self.lifxClient.dataHandler = ^void(NSDictionary* data) {
Expand Down

0 comments on commit 706ef54

Please sign in to comment.