Skip to content

Commit

Permalink
Bump version to 0.17.0
Browse files Browse the repository at this point in the history
Improve setting new preference to apps with bundle identifiers that
use lowercased naming
Add longer delay to make sure that the settings aggregate properly
  • Loading branch information
zenangst committed May 25, 2021
1 parent f6e9453 commit 397bdf3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Gray.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.16.0;
MARKETING_VERSION = 0.17.0;
PRODUCT_BUNDLE_IDENTIFIER = com.zenangst.Gray;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -745,7 +745,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.16.0;
MARKETING_VERSION = 0.17.0;
PRODUCT_BUNDLE_IDENTIFIER = com.zenangst.Gray;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
12 changes: 6 additions & 6 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PODS:
- UserInterface (0.5.0)

DEPENDENCIES:
- "Blueprints (from `git@github.com:zenangst/Blueprints.git`, branch `feature/preferred-layout-attributes`)"
- Blueprints (from `https://github.com/zenangst/Blueprints.git`, branch `feature/preferred-layout-attributes`)
- Differific
- Family
- Sourcery
Expand All @@ -22,12 +22,12 @@ SPEC REPOS:
EXTERNAL SOURCES:
Blueprints:
:branch: feature/preferred-layout-attributes
:git: "git@github.com:zenangst/Blueprints.git"
:git: https://github.com/zenangst/Blueprints.git

CHECKOUT OPTIONS:
Blueprints:
:commit: 6719ed1aba5cfca311ae04d1035832755116dfc0
:git: "git@github.com:zenangst/Blueprints.git"
:commit: 576191d2b834805635824cc5f6db8ff3ea76b7ad
:git: https://github.com/zenangst/Blueprints.git

SPEC CHECKSUMS:
Blueprints: ddd6ab1e455c98471aaef2fdd0b09b5f9b53af5b
Expand All @@ -36,6 +36,6 @@ SPEC CHECKSUMS:
Sourcery: 3ed61be7c8a1218fce349266139379dba477efe0
UserInterface: 54e15db9aceaec2b9686d00f471adb15d2598ea3

PODFILE CHECKSUM: 2c8c2d81b994943738c4544119e5d29b6bb5f0fe
PODFILE CHECKSUM: ec46b4f2901d457ac7f8988c354b20dac9182b1a

COCOAPODS: 1.9.1
COCOAPODS: 1.10.1
28 changes: 17 additions & 11 deletions Sources/Features/Applications/ApplicationsLogicController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ class ApplicationsLogicController {
queue.async { [weak self] in
let shell = Shell()

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

if !application.url.path.contains("CoreServices") {
runningApplication?.terminate()
}

// The cfprefsd is killed for the current user to avoid plist caching.
// PlistBuddy is used to set new values.
// Defaults is invoked in order to renew the cache.
Expand All @@ -53,44 +59,44 @@ class ApplicationsLogicController {
case .light:
command = """
defaults write \(application.bundleIdentifier) NSRequiresAquaSystemAppearance -bool true
defaults write \(application.bundleIdentifier.lowercased()) NSRequiresAquaSystemAppearance -bool true
defaults read \(application.bundleIdentifier) NSRequiresAquaSystemAppearance \(application.preferencesUrl.path)
"""
case .dark:
command = """
defaults write \(application.bundleIdentifier) NSRequiresAquaSystemAppearance -bool false
defaults write \(application.bundleIdentifier.lowercased()) NSRequiresAquaSystemAppearance -bool false
defaults read \(application.bundleIdentifier) NSRequiresAquaSystemAppearance \(application.preferencesUrl.path)
"""
case .system:
command = """
defaults delete \(application.bundleIdentifier) NSRequiresAquaSystemAppearance
defaults delete \(application.bundleIdentifier.lowercased()) NSRequiresAquaSystemAppearance
defaults read \(application.bundleIdentifier) NSRequiresAquaSystemAppearance \(application.preferencesUrl.path)
"""
}

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

if !application.url.path.contains("CoreServices") {
runningApplication?.terminate()
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
let output = shell.execute(command: command)
NSLog("Gray: terminal output: (\(output))")
self?.load()
}

NSLog("Gray: New settings for \(application.name) = \(newAppearance)")
NSLog("Gray: Command: \(command)")
let output = shell.execute(command: command)
NSLog("Gray: terminal output: (\(output))")

if runningApplication != nil && !application.url.path.contains("CoreServices") {
self?.queue.asyncAfter(deadline: .now() + 0.5, execute: {
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
NSWorkspace.shared.launchApplication(withBundleIdentifier: application.bundleIdentifier,
options: [.withoutActivation],
additionalEventParamDescriptor: nil,
launchIdentifier: nil)
})
}
} else {
let shell = Shell()
shell.execute(command: "killall", arguments: ["-9", "\(application.name)"])
}

self?.load()
NSLog("Gray: New settings for \(application.name) = \(newAppearance)")
NSLog("Gray: Command: \(command)")
}
}

Expand Down

0 comments on commit 397bdf3

Please sign in to comment.