aboutsummaryrefslogtreecommitdiffstats
path: root/Low Battery Yup
diff options
context:
space:
mode:
authorTeddy Wing2016-12-02 16:45:45 -0500
committerTeddy Wing2016-12-02 16:45:45 -0500
commite5debc332f2b11f4e768e0a5b0f2b8770c25523e (patch)
treec57bfb8f5dd8bf6000cf0ef3116d4f283140c374 /Low Battery Yup
parentac1d82e1fff9039a5dabe1404d6f03faaad28ef5 (diff)
downloadLow-Battery-Yup-e5debc332f2b11f4e768e0a5b0f2b8770c25523e.tar.bz2
DaemonLauncher.m: Check if daemon is running before launch or quit
If the daemon is already running when `launch` is called, don't bother launching. If the daemon is not running when `quit` is called, don't bother quitting.
Diffstat (limited to 'Low Battery Yup')
-rw-r--r--Low Battery Yup/DaemonLauncher.m8
1 files changed, 8 insertions, 0 deletions
diff --git a/Low Battery Yup/DaemonLauncher.m b/Low Battery Yup/DaemonLauncher.m
index 355e9fd..b96af44 100644
--- a/Low Battery Yup/DaemonLauncher.m
+++ b/Low Battery Yup/DaemonLauncher.m
@@ -12,6 +12,10 @@
- (BOOL)launch
{
+ if ([self isRunning]) {
+ return NO;
+ }
+
NSURL *daemon_url = [[NSBundle mainBundle] URLForResource:@"Low Battery Yup.d" withExtension:@"app"];
NSError *error = nil;
@@ -31,6 +35,10 @@
- (BOOL)quit
{
+ if (![self isRunning]) {
+ return NO;
+ }
+
NSArray *applications = [NSRunningApplication
runningApplicationsWithBundleIdentifier:@"com.teddywing.Low-Battery-Yup-d"];