aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2021-03-07 13:49:24 +0100
committerTeddy Wing2021-03-07 13:49:24 +0100
commit0b75559334510592ba6064bcb66657cdda36b758 (patch)
treed2ef4fa52789c87897678badd8fd1cd8fc211895
parenta31659a57f469eac3f833f49d3b809302753c088 (diff)
downloadRe-Good-Catalina-Invert-Colours-0b75559334510592ba6064bcb66657cdda36b758.tar.bz2
register_hotkeys: Add error handling
Fail to start if we can't register hotkeys.
-rw-r--r--main.m15
1 files changed, 13 insertions, 2 deletions
diff --git a/main.m b/main.m
index 87e64c0..c04c2c8 100644
--- a/main.m
+++ b/main.m
@@ -1,8 +1,12 @@
#import <Carbon/Carbon.h>
+#include <sysexits.h>
+
#import "Invert.h"
#import "DDHotKeyCenter.h"
+#define E_REGISTER_HOTKEY 5
+
int register_hotkeys();
int main(int argc, const char * argv[]) {
@@ -11,6 +15,9 @@ int main(int argc, const char * argv[]) {
[NSApplication sharedApplication];
int error_code = register_hotkeys();
+ if (error_code == E_REGISTER_HOTKEY) {
+ return EX_SOFTWARE;
+ }
[NSApp run];
@@ -29,7 +36,9 @@ int register_hotkeys() {
action:@selector(toggleInvertColors:)
object:nil]
) {
- NSLog(@"Error registering hotkey");
+ NSLog(@"Error registering hotkey Apple+Option+Control-8");
+
+ return E_REGISTER_HOTKEY;
}
if (
@@ -39,7 +48,9 @@ int register_hotkeys() {
action:@selector(toggleInvertColors:)
object:nil]
) {
- NSLog(@"Error registering hotkey");
+ NSLog(@"Error registering hotkey F8");
+
+ return E_REGISTER_HOTKEY;
}
return 0;