Skip to content

Commit

Permalink
Merge pull request #30 from zenangst/refactor/application-toggle
Browse files Browse the repository at this point in the history
Refactor application toggle
  • Loading branch information
zenangst authored Oct 5, 2018
2 parents 6b213f3 + 305ec16 commit f76ef53
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Gray.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
BD1BA9BE215E68840052633B /* IconController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1BA9BD215E68840052633B /* IconController.swift */; };
BD1BA9C0215E6DBB0052633B /* ApplicationGridView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1BA9BF215E6DBB0052633B /* ApplicationGridView.swift */; };
BD1D9545215E435F003ABBCF /* VersionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1D9544215E435F003ABBCF /* VersionController.swift */; };
BD2AA1E62167A0E4000717B7 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = BD2AA1E52167A0E4000717B7 /* README.md */; };
BD30844A215C198D002A9349 /* ApplicationsLogicController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD308449215C198D002A9349 /* ApplicationsLogicController.swift */; };
BD67CE0E215BF15F00216FDB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD67CE0D215BF15F00216FDB /* AppDelegate.swift */; };
BD67CE10215BF16100216FDB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BD67CE0F215BF16100216FDB /* Assets.xcassets */; };
Expand All @@ -35,6 +36,7 @@
BD1BA9BD215E68840052633B /* IconController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconController.swift; sourceTree = "<group>"; };
BD1BA9BF215E6DBB0052633B /* ApplicationGridView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationGridView.swift; sourceTree = "<group>"; };
BD1D9544215E435F003ABBCF /* VersionController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionController.swift; sourceTree = "<group>"; };
BD2AA1E52167A0E4000717B7 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
BD308449215C198D002A9349 /* ApplicationsLogicController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationsLogicController.swift; sourceTree = "<group>"; };
BD67CE0A215BF15F00216FDB /* Gray.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Gray.app; sourceTree = BUILT_PRODUCTS_DIR; };
BD67CE0D215BF15F00216FDB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -98,6 +100,7 @@
BD67CE01215BF15F00216FDB = {
isa = PBXGroup;
children = (
BD2AA1E52167A0E4000717B7 /* README.md */,
BD9F0C532166997900608FD9 /* Gray.entitlements */,
BD111047215CEB8E0002D537 /* Sources */,
BD67CE0C215BF15F00216FDB /* Resources */,
Expand Down Expand Up @@ -325,6 +328,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BD2AA1E62167A0E4000717B7 /* README.md in Resources */,
BD67CE10215BF16100216FDB /* Assets.xcassets in Resources */,
BD67CE13215BF16100216FDB /* MainMenu.xib in Resources */,
);
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<img src="https://github.com/zenangst/Gray/blob/master/Resources/Assets.xcassets/AppIcon.appiconset/icon_256x256.png?raw=true" alt="Gray Icon" align="right" />

Current version: 0.5.1 [[Download](https://github.com/zenangst/Gray/releases/download/0.5.1/Gray.zip)]
Current version: 0.5.2 [[Download](https://github.com/zenangst/Gray/releases/download/0.5.2/Gray.zip)]

Ever wanted to have light and dark apps live side-by-side in harmony? Well, now you can. With **Gray** you can pick between the light appearance and the dark appearance on a per-app basis with the click of a button.

Expand Down
2 changes: 1 addition & 1 deletion Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.5.1</string>
<string>0.5.2</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
Expand Down
16 changes: 14 additions & 2 deletions Sources/Applications/Logic/ApplicationsLogicController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ class ApplicationsLogicController {
then handler: @escaping (MainViewController.State) -> Void) {
DispatchQueue.global(qos: .userInitiated).async { [weak self] in
let shell = Shell()
let newSetting = appearance == .light ? "YES" : "NO"
let newSetting: String
switch appearance {
case .light, .system:
newSetting = "true"
case .dark:
newSetting = "false"
}

let runningApplication = NSRunningApplication.runningApplications(withBundleIdentifier: application.bundleIdentifier).first

if !application.url.path.contains("CoreServices") {
Expand All @@ -55,7 +62,12 @@ class ApplicationsLogicController {
"""
}

shell.execute(command: command)
NSLog("New settings for \(application.name) = \(newSetting)")
NSLog("command: \(command)")

let output = shell.execute(command: command)
NSLog("output: (\(output))")


if runningApplication != nil && !application.url.path.contains("CoreServices") {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2, execute: {
Expand Down

0 comments on commit f76ef53

Please sign in to comment.