-
Notifications
You must be signed in to change notification settings - Fork 33
Disabling night shift for an application fails for certain applications - Could not obtain bundle identifier of current application #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I took a quick look at the Parsec app bundle and inside there's an additional executable for the window. We use the |
@choco Sounds logical. Happy to test if you want to build me a binary. |
This is a just a quick test binary using executableUrl as fallback. I haven't tested it myself but it should work! Shifty.app.zip diff --git a/Shifty/RuleManager.swift b/Shifty/RuleManager.swift
index ecdf862..222791e 100644
--- a/Shifty/RuleManager.swift
+++ b/Shifty/RuleManager.swift
@@ -27,15 +27,16 @@ enum SubdomainRuleType: String, Codable {
struct AppRule: CustomStringConvertible, Hashable, Codable {
- var bundleIdentifier: BundleIdentifier
+ var bundleIdentifier: BundleIdentifier?
+ var executableURL: URL?
var fullScreenOnly: Bool
var description: String {
- return "Rule for \(bundleIdentifier); full screen only: \(fullScreenOnly)"
+ return "Rule for \(bundleIdentifier ?? "unknown") located \(executableURL?.absoluteString ?? "not set"); full screen only: \(fullScreenOnly)"
}
static func == (lhs: AppRule, rhs: AppRule) -> Bool {
- return lhs.bundleIdentifier == rhs.bundleIdentifier
+ return ((lhs.bundleIdentifier == rhs.bundleIdentifier) || (lhs.executableURL == rhs.executableURL))
&& lhs.fullScreenOnly == rhs.fullScreenOnly
}
}
@@ -86,19 +87,34 @@ enum RuleManager {
static var disabledForApp: Bool {
get {
- guard let bundleIdentifier = currentApp?.bundleIdentifier else {
+ if let bundleIdentifier = currentApp?.bundleIdentifier {
+ return disabledApps.filter {
+ $0.bundleIdentifier == bundleIdentifier }.count > 0
+ } else {
logw("Could not obtain bundle identifier of current application")
- return false
+
+ guard let executableURL = currentApp?.executableURL else {
+ logw("Could not obtain executable url of current application")
+ return false
+ }
+ return disabledApps.filter {
+ $0.executableURL == executableURL }.count > 0
}
- return disabledApps.filter {
- $0.bundleIdentifier == bundleIdentifier }.count > 0
}
set(newValue) {
- guard let bundleIdentifier = currentApp?.bundleIdentifier else {
- logw("Could not obtain bundle identifier of current application")
- return
+ var rule : AppRule
+ if let bundleIdentifier = currentApp?.bundleIdentifier {
+ rule = AppRule(bundleIdentifier: bundleIdentifier,
+ executableURL: nil, fullScreenOnly: false)
+ } else {
+ guard let executableURL = currentApp?.executableURL else {
+ logw("Could not obtain executable url of current application")
+ return
+ }
+ rule = AppRule(bundleIdentifier: nil,
+ executableURL: executableURL, fullScreenOnly: false)
}
- let rule = AppRule(bundleIdentifier: bundleIdentifier, fullScreenOnly: false)
+
if newValue {
disabledApps.insert(rule)
NightShiftManager.respond(to: .nightShiftDisableRuleActivated)
|
I can confirm, that works perfectly. Disabling for the Parsec Game Window doesn't disable it for the regular Parsec window, as expected. Thanks! |
Nice! 🎉 |
Certainly. That one also works correctly. |
I've merged @choco's fix. Thank you both! |
Actually, this'll take a little more work, since fixing this has some side effects that need more time to deal with (see #76). Reopening for now. |
I've had to stop using shifty because of this, I hope that this doesn't take much to fix again and can be fixed soon. |
I use Parsec (https://parsecgaming.com/) which, when connected to another machine, spawns a Parsec Game Window. I'm unable to disable night shift on just the Parsec Game Window, and the logs say "Could not obtain bundle identifier of current application" whenever I try to click the option moused over in the screenshot.
Disabling for the regular Parsec window works fine - but that doesn't also disable night shift on the actual game window - and my games look much better without night shift on!
Please let me know if there's any other information you'd like.
The text was updated successfully, but these errors were encountered: