Skip to content

Commit

Permalink
feat: blacklisting apps can use start of the bundle id (closes #549)
Browse files Browse the repository at this point in the history
Also handle Parallels better
  • Loading branch information
lwouis committed Aug 24, 2020
1 parent 8399f84 commit de9cf46
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/logic/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Preferences {
"startAtLogin": "true",
"menubarIcon": "0",
"dontShowBlacklist": "",
"disableShortcutsBlacklist": ["com.realvnc.vncviewer", "com.microsoft.rdc.macos", "com.teamviewer.TeamViewer", "org.virtualbox.app.VirtualBoxVM", "com.parallels.vm", "com.citrix.XenAppViewer"].joined(separator: "\n"),
"disableShortcutsBlacklist": ["com.realvnc.vncviewer", "com.microsoft.rdc.macos", "com.teamviewer.TeamViewer", "org.virtualbox.app.VirtualBoxVM", "com.parallels.", "com.citrix.XenAppViewer"].joined(separator: "\n"),
"disableShortcutsBlacklistOnlyFullscreen": "true",
"updatePolicy": "1",
"crashPolicy": "1",
Expand Down Expand Up @@ -177,7 +177,13 @@ class Preferences {
}

static func blacklistStringToArray(_ blacklist: String) -> [String] {
return blacklist.components(separatedBy: "\n").map { $0.trimmingCharacters(in: .whitespaces) }
return blacklist.components(separatedBy: "\n").compactMap {
let line = $0.trimmingCharacters(in: .whitespaces)
if line.isEmpty {
return nil
}
return line
}
}

static func defaultsDependingOnScreenRatio() -> [String: String] {
Expand Down
10 changes: 7 additions & 3 deletions src/logic/Windows.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,13 @@ class Windows {

static func checkIfShortcutsShouldBeDisabled() {
if let activeWindow = list.first {
App.app.shortcutsShouldBeDisabled =
Preferences.disableShortcutsBlacklist.contains(activeWindow.application.runningApplication.bundleIdentifier ?? "") &&
(!Preferences.disableShortcutsBlacklistOnlyFullscreen || activeWindow.isFullscreen)
App.app.shortcutsShouldBeDisabled = (!Preferences.disableShortcutsBlacklistOnlyFullscreen || activeWindow.isFullscreen) &&
(Preferences.disableShortcutsBlacklist.first { blacklistedId in
if let id = activeWindow.application.runningApplication.bundleIdentifier {
return id.hasPrefix(blacklistedId)
}
return false
} != nil)
if App.app.shortcutsShouldBeDisabled && App.app.appIsBeingUsed {
App.app.hideUi()
}
Expand Down

0 comments on commit de9cf46

Please sign in to comment.