Skip to content

Commit

Permalink
Implement autostart on login
Browse files Browse the repository at this point in the history
  • Loading branch information
heyvito committed Oct 16, 2017
1 parent a75134d commit d611ebe
Show file tree
Hide file tree
Showing 23 changed files with 743 additions and 78 deletions.
42 changes: 38 additions & 4 deletions Bedim.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
DA1448C11F93C7F7008388FA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DA1448C01F93C7F6008388FA /* Assets.xcassets */; };
DA1448C31F93D1E2008388FA /* MASPreferences.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA1448C21F93D1E1008388FA /* MASPreferences.framework */; };
DA1448C41F93D1E2008388FA /* MASPreferences.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DA1448C21F93D1E1008388FA /* MASPreferences.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
DA8F50141F943A6C0032C154 /* BedimHelper.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = DA8F50131F943A650032C154 /* BedimHelper.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
DABA2B201F92AE720029EC09 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DABA2B1F1F92AE720029EC09 /* AppDelegate.m */; };
DABA2B281F92AE720029EC09 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DABA2B261F92AE720029EC09 /* Main.storyboard */; };
DABA2B2B1F92AE720029EC09 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = DABA2B2A1F92AE720029EC09 /* main.m */; };
Expand All @@ -29,7 +30,10 @@
DABEF7BB1F93F3930059A631 /* BDAboutViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = DABEF7B91F93F3930059A631 /* BDAboutViewController.xib */; };
DABEF7BD1F93F4980059A631 /* Licenses in Resources */ = {isa = PBXBuildFile; fileRef = DABEF7BC1F93F4980059A631 /* Licenses */; };
DABEF7C01F93FE1A0059A631 /* BDFileSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = DABEF7BF1F93FE1A0059A631 /* BDFileSystem.m */; };
DAF2E2601F94118700276845 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = DAF2E25F1F94118700276845 /* README.md */; };
DAEBDC991F9427720017DF80 /* LetsMove.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DAEBDC981F9427720017DF80 /* LetsMove.framework */; };
DAEBDC9A1F9427720017DF80 /* LetsMove.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DAEBDC981F9427720017DF80 /* LetsMove.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
DAF1EB921F9427CC00063D79 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DAF1EB911F9427CC00063D79 /* Security.framework */; };
DAF1EB971F942AE900063D79 /* ServiceManagement.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DAF1EB961F942AE900063D79 /* ServiceManagement.framework */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -40,10 +44,21 @@
dstSubfolderSpec = 10;
files = (
DA1448C41F93D1E2008388FA /* MASPreferences.framework in Embed Frameworks */,
DAEBDC9A1F9427720017DF80 /* LetsMove.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
DA8F500E1F9439CA0032C154 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = Contents/Library/LoginItems;
dstSubfolderSpec = 1;
files = (
DA8F50141F943A6C0032C154 /* BedimHelper.app in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
Expand All @@ -62,6 +77,7 @@
DA1448BD1F932E3E008388FA /* BDSettingsViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = BDSettingsViewController.xib; sourceTree = "<group>"; };
DA1448C01F93C7F6008388FA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
DA1448C21F93D1E1008388FA /* MASPreferences.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MASPreferences.framework; path = ../Carthage/Build/Mac/MASPreferences.framework; sourceTree = "<group>"; };
DA8F50131F943A650032C154 /* BedimHelper.app */ = {isa = PBXFileReference; lastKnownFileType = wrapper.application; name = BedimHelper.app; path = "../../../Library/Developer/Xcode/DerivedData/Bedim-funojulxhpaycybcfxwpsbcyugvw/Build/Products/Debug/BedimHelper.app"; sourceTree = "<group>"; };
DABA2B1B1F92AE720029EC09 /* Bedim.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Bedim.app; sourceTree = BUILT_PRODUCTS_DIR; };
DABA2B1E1F92AE720029EC09 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
DABA2B1F1F92AE720029EC09 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
Expand All @@ -85,15 +101,20 @@
DABEF7BC1F93F4980059A631 /* Licenses */ = {isa = PBXFileReference; lastKnownFileType = text; path = Licenses; sourceTree = "<group>"; };
DABEF7BE1F93FE1A0059A631 /* BDFileSystem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BDFileSystem.h; sourceTree = "<group>"; };
DABEF7BF1F93FE1A0059A631 /* BDFileSystem.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BDFileSystem.m; sourceTree = "<group>"; };
DAF2E25F1F94118700276845 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
DAEBDC981F9427720017DF80 /* LetsMove.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LetsMove.framework; path = ../Carthage/Build/Mac/LetsMove.framework; sourceTree = "<group>"; };
DAF1EB911F9427CC00063D79 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
DAF1EB961F942AE900063D79 /* ServiceManagement.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ServiceManagement.framework; path = System/Library/Frameworks/ServiceManagement.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
DABA2B181F92AE720029EC09 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
DAF1EB971F942AE900063D79 /* ServiceManagement.framework in Frameworks */,
DAF1EB921F9427CC00063D79 /* Security.framework in Frameworks */,
DA1448C31F93D1E2008388FA /* MASPreferences.framework in Frameworks */,
DAEBDC991F9427720017DF80 /* LetsMove.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -131,6 +152,8 @@
DA14489B1F93062B008388FA /* Support Files */ = {
isa = PBXGroup;
children = (
DA8F50131F943A650032C154 /* BedimHelper.app */,
DAEBDC981F9427720017DF80 /* LetsMove.framework */,
DA1448C21F93D1E1008388FA /* MASPreferences.framework */,
DA1448C01F93C7F6008388FA /* Assets.xcassets */,
DABA2B291F92AE720029EC09 /* Info.plist */,
Expand Down Expand Up @@ -167,9 +190,9 @@
DABA2B121F92AE720029EC09 = {
isa = PBXGroup;
children = (
DAF2E25F1F94118700276845 /* README.md */,
DABA2B1D1F92AE720029EC09 /* Bedim */,
DABA2B1C1F92AE720029EC09 /* Products */,
DAF1EB901F9427CC00063D79 /* Frameworks */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -217,6 +240,15 @@
path = BDAboutViewController;
sourceTree = "<group>";
};
DAF1EB901F9427CC00063D79 /* Frameworks */ = {
isa = PBXGroup;
children = (
DAF1EB961F942AE900063D79 /* ServiceManagement.framework */,
DAF1EB911F9427CC00063D79 /* Security.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand All @@ -228,6 +260,7 @@
DABA2B181F92AE720029EC09 /* Frameworks */,
DABA2B191F92AE720029EC09 /* Resources */,
DA1448C51F93D1E2008388FA /* Embed Frameworks */,
DA8F500E1F9439CA0032C154 /* CopyFiles */,
);
buildRules = (
);
Expand Down Expand Up @@ -281,7 +314,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DAF2E2601F94118700276845 /* README.md in Resources */,
DA1448BF1F932E3E008388FA /* BDSettingsViewController.xib in Resources */,
DABA2B281F92AE720029EC09 /* Main.storyboard in Resources */,
DABEF7BB1F93F3930059A631 /* BDAboutViewController.xib in Resources */,
Expand Down Expand Up @@ -445,6 +477,7 @@
);
INFOPLIST_FILE = Bedim/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = io.vito.Bedim;
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand All @@ -463,6 +496,7 @@
);
INFOPLIST_FILE = Bedim/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = io.vito.Bedim;
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand Down
13 changes: 13 additions & 0 deletions Bedim.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion Bedim/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
//

#import <MASPreferences/MASPreferences.h>
#import <LetsMove/LetsMove.h>
#import "AppDelegate.h"
#import "BDWorkspace.h"
#import "BDEventRouter.h"
#import "BDFileSystem.h"
#import "BDSettingsViewController.h"
#import "BDAboutViewController.h"

Expand All @@ -32,8 +34,12 @@ - (void)applicationWillTerminate:(NSNotification *)aNotification {
[work removeBlurEffect];
}

- (void)applicationWillFinishLaunching:(NSNotification *)notification {
PFMoveToApplicationsFolderIfNecessary();
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// [NSApp activateIgnoringOtherApps:YES];
[BDFileSystem isRunningFromApplicationsFolder];
self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
[self.statusItem setMenu:self.statusMenu];
self.statusItem.image = [NSImage imageNamed:@"status_icon"];
Expand Down
4 changes: 2 additions & 2 deletions Bedim/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.0.1</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>27</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
1 change: 1 addition & 0 deletions Bedim/Integration/BDFileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
+ (nonnull NSString *)cachePathForImageWithPath:(nonnull NSString *)original;
+ (nonnull NSString *)cachePath;
+ (void)clearCache;
+ (BOOL)isRunningFromApplicationsFolder;
@end
26 changes: 17 additions & 9 deletions Bedim/Integration/BDFileSystem.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ + (unsigned long long)getFolderSize:(NSString *)folderPath {
} else {
if(S_ISREG(linfo.st_mode)) {
totalSize += linfo.st_size;
} else {
free(dName);
}
}
free(dName);
}
}

Expand All @@ -79,15 +78,24 @@ + (NSString *)cachePathForImageWithPath:(NSString *)original {
return [[self cachePath] stringByAppendingPathComponent:[BDUtility digestString:original]];
}

+ (BOOL)isRunningFromApplicationsFolder {
NSArray<NSURL *> *applicationFolders = [[NSFileManager defaultManager] URLsForDirectory:NSApplicationDirectory inDomains:NSLocalDomainMask | NSUserDomainMask];
NSString *appPath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
for(NSURL *url in applicationFolders) {
if([[url path] isEqualToString:appPath]) {
return YES;
}
}
return NO;
}

+ (NSString *)cachePath {
NSString *path = nil;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
if ([paths count]) {
NSString *bundleName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];
path = [[paths objectAtIndex:0] stringByAppendingPathComponent:bundleName];
if(![[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:nil]) {
[[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
}
NSString *bundleName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];
path = [[paths objectAtIndex:0] stringByAppendingPathComponent:bundleName];
if(![[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:nil]) {
[[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
}
return path;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ @implementation BDAboutViewController

- (void)viewDidLoad {
[super viewDidLoad];
}

- (void)viewWillAppear {
[super viewWillAppear];
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [bundle pathForResource:@"Licenses" ofType:@""];
NSString *contents = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13196" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13196"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -18,46 +19,46 @@
<rect key="frame" x="0.0" y="0.0" width="569" height="364"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="H2W-yR-itN">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="H2W-yR-itN">
<rect key="frame" x="18" y="327" width="58" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Bedim" id="dkh-Kn-rve">
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Bedim" id="dkh-Kn-rve">
<font key="font" size="16" name=".AppleSystemUIFont"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Zdq-fk-RA4">
<rect key="frame" x="18" y="309" width="70" height="17"/>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Zdq-fk-RA4">
<rect key="frame" x="18" y="309" width="205" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Version 1.0" id="4xP-8n-Ypj">
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Version 1.0" id="4xP-8n-Ypj">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pXq-kg-kT1">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pXq-kg-kT1">
<rect key="frame" x="18" y="292" width="205" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Copyright (c) 2017 - Victor Gama" id="0hB-Fu-WOO">
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Copyright (c) 2017 - Victor Gama" id="0hB-Fu-WOO">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<scrollView fixedFrame="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" scrollerKnobStyle="dark" translatesAutoresizingMaskIntoConstraints="NO" id="0bW-Gg-hWt">
<rect key="frame" x="20" y="20" width="529" height="264"/>
<rect key="frame" x="20" y="20" width="529" height="254"/>
<autoresizingMask key="autoresizingMask"/>
<clipView key="contentView" ambiguous="YES" id="7l6-D1-L32">
<rect key="frame" x="1" y="1" width="527" height="262"/>
<rect key="frame" x="1" y="1" width="527" height="252"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView ambiguous="YES" editable="NO" selectable="NO" importsGraphics="NO" richText="NO" verticallyResizable="YES" findStyle="panel" allowsCharacterPickerTouchBarItem="NO" allowsNonContiguousLayout="YES" textCompletion="NO" id="mT9-do-run">
<rect key="frame" x="0.0" y="0.0" width="527" height="262"/>
<rect key="frame" x="0.0" y="0.0" width="527" height="252"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<size key="minSize" width="527" height="262"/>
<size key="maxSize" width="527" height="10000000"/>
<size key="minSize" width="527" height="252"/>
<size key="maxSize" width="529" height="10000000"/>
<color key="insertionPointColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
</textView>
</subviews>
Expand All @@ -68,7 +69,7 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="GYD-xV-9JB">
<rect key="frame" x="512" y="1" width="16" height="262"/>
<rect key="frame" x="512" y="1" width="16" height="252"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
Expand Down
Loading

0 comments on commit d611ebe

Please sign in to comment.