Skip to content

Commit

Permalink
Use user's home directory for config
Browse files Browse the repository at this point in the history
  • Loading branch information
richinfante committed Feb 15, 2019
1 parent edf6184 commit 3112cf4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 9 additions & 1 deletion shbar2/AppDelegate.swift
Expand Up @@ -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)
Expand Down
10 changes: 6 additions & 4 deletions shbar2/Info.plist
Expand Up @@ -17,18 +17,20 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>0.0.1</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>2</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>LSUIElement</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2019 Rich Infante. All rights reserved.</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>LSUIElement</key>
<true/>
</dict>
</plist>

0 comments on commit 3112cf4

Please sign in to comment.