aboutsummaryrefslogtreecommitdiffstats
path: root/Low Battery Yup
diff options
context:
space:
mode:
authorTeddy Wing2016-12-02 16:39:21 -0500
committerTeddy Wing2016-12-02 16:39:21 -0500
commitac1d82e1fff9039a5dabe1404d6f03faaad28ef5 (patch)
treecf5d90b09ec4ee333951874363177874b982c532 /Low Battery Yup
parent7a11bfeb961f52dc9e840c1db7161ad08c436aff (diff)
downloadLow-Battery-Yup-ac1d82e1fff9039a5dabe1404d6f03faaad28ef5.tar.bz2
DaemonLauncher: Add `isRunning` method
Says whether or not the daemon app is currently running.
Diffstat (limited to 'Low Battery Yup')
-rw-r--r--Low Battery Yup/DaemonLauncher.h1
-rw-r--r--Low Battery Yup/DaemonLauncher.m14
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