diff options
| author | Teddy Wing | 2021-03-07 13:49:24 +0100 |
|---|---|---|
| committer | Teddy Wing | 2021-03-07 13:49:24 +0100 |
| commit | 0b75559334510592ba6064bcb66657cdda36b758 (patch) | |
| tree | d2ef4fa52789c87897678badd8fd1cd8fc211895 | |
| parent | a31659a57f469eac3f833f49d3b809302753c088 (diff) | |
| download | Re-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.m | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -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; |
