diff options
| author | Teddy Wing | 2016-12-02 16:39:21 -0500 |
|---|---|---|
| committer | Teddy Wing | 2016-12-02 16:39:21 -0500 |
| commit | ac1d82e1fff9039a5dabe1404d6f03faaad28ef5 (patch) | |
| tree | cf5d90b09ec4ee333951874363177874b982c532 | |
| parent | 7a11bfeb961f52dc9e840c1db7161ad08c436aff (diff) | |
| download | Low-Battery-Yup-ac1d82e1fff9039a5dabe1404d6f03faaad28ef5.tar.bz2 | |
DaemonLauncher: Add `isRunning` method
Says whether or not the daemon app is currently running.
| -rw-r--r-- | Low Battery Yup/DaemonLauncher.h | 1 | ||||
| -rw-r--r-- | Low Battery Yup/DaemonLauncher.m | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/Low Battery Yup/DaemonLauncher.h b/Low Battery Yup/DaemonLauncher.h index a7c6ceb..586dbda 100644 --- a/Low Battery Yup/DaemonLauncher.h +++ b/Low Battery Yup/DaemonLauncher.h @@ -12,5 +12,6 @@ - (BOOL)launch; - (BOOL)quit; +- (BOOL)isRunning; @end diff --git a/Low Battery Yup/DaemonLauncher.m b/Low Battery Yup/DaemonLauncher.m index 78b7844..355e9fd 100644 --- a/Low Battery Yup/DaemonLauncher.m +++ b/Low Battery Yup/DaemonLauncher.m @@ -42,4 +42,18 @@ return NO; } +- (BOOL)isRunning +{ + NSArray *runningApplications = [[NSWorkspace sharedWorkspace] runningApplications]; + + for (int i = 0; i < [runningApplications count]; i++) { + if ([[[runningApplications objectAtIndex:i] bundleIdentifier] + isEqualToString:@"com.teddywing.Low-Battery-Yup-d"]) { + return YES; + } + } + + return NO; +} + @end |
