From 3112cf465a9a34f86d8fa5800a17aaea76b06903 Mon Sep 17 00:00:00 2001 From: Rich Infante Date: Fri, 15 Feb 2019 09:18:50 -0500 Subject: [PATCH] Use user's home directory for config --- shbar2/AppDelegate.swift | 10 +++++++++- shbar2/Info.plist | 10 ++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/shbar2/AppDelegate.swift b/shbar2/AppDelegate.swift index 62ee384..d932ad9 100644 --- a/shbar2/AppDelegate.swift +++ b/shbar2/AppDelegate.swift @@ -307,8 +307,16 @@ class AppDelegate: NSObject, NSApplicationDelegate { let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) + var userHomeDirectoryPath : String { + let pw = getpwuid(getuid()) + let home = pw?.pointee.pw_dir + let homePath = FileManager.default.string(withFileSystemRepresentation: home!, length: Int(strlen(home))) + + return homePath + } + func applicationDidFinishLaunching(_ aNotification: Notification) { - let json = try? Data(contentsOf: URL(fileURLWithPath: "/Users/rich/.config/shbar/shbar.json")) + let json = try? Data(contentsOf: URL(fileURLWithPath: "\(userHomeDirectoryPath)/.config/shbar/shbar.json")) if let json = json { let decoder = JSONDecoder() let decodedItems = try? decoder.decode([ItemConfig].self, from: json) diff --git a/shbar2/Info.plist b/shbar2/Info.plist index 9441832..4031539 100644 --- a/shbar2/Info.plist +++ b/shbar2/Info.plist @@ -17,18 +17,20 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0 + 0.0.1 CFBundleVersion - 1 + 2 + LSApplicationCategoryType + public.app-category.developer-tools LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) + LSUIElement + NSHumanReadableCopyright Copyright © 2019 Rich Infante. All rights reserved. NSMainStoryboardFile Main NSPrincipalClass NSApplication - LSUIElement -