Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does
This PR allows keystroke actions to be performed on only the active screen of specified screens.
Current behaviour
Currently keystroke actions behave as such:
keystroke(Control) = keystroke(Super)
- performs on the active screen only, but with no way to have custom keystrokes for different screenskeystroke(Control) = keystroke(Super,Mac-Mini)
- always performs on the specified screens, regardless of whether they are active, and no way to target a specific oneNew behaviour (
activeScreenOnly
option)This PR adds a new optional setting
activeScreenOnly
to keystroke actions, used as such:keystroke(Control) = keystroke(Super,Mac-Mini,activeScreenOnly)
- performs onMac-Mini
, and only when it is activeAs normal, keystroke actions can be chained, meaning that we can have different shortcuts for different screens, and only when those screens are active:
keystroke(Control) = keystroke(Super,Mac-Mini:Mac-Pro,activeScreenOnly),keystroke(Alt,Laptop,activeScreenOnly)
- changesControl->Super
onMac-Mini
andMac-Pro
, andControl->Alt
onLaptop
, and only on the one that is activeWindows and macOS server specifics (
disableGlobalHotkeyRegister
option)On Windows and macOS this works for both server and clients, with the exception being for keystroke actions intended for the server where the keystroke matches the condition (for instance, adding a custom action on a client, but preserving the original keystroke on the server) e.g.
keystroke(Control) = keystroke(Super,Mac-Mini,activeScreenOnly), keystroke(Alt,Server,activeScreenOnly)
- this works on Serverkeystroke(Control) = keystroke(Super,Mac-Mini,activeScreenOnly), keystroke(Control,Server,activeScreenOnly)
- this does not work on ServerSince Barrier registers a hotkey for the keystroke condition on the server, this prevents the ability to specify the original keystroke as an action for the server. For this, a new option
disableGlobalHotkeyRegister
for the condition allows disabling hotkey registration with the OS. This allows the original keystroke to be performed on the server when it is in focus i.e.keystroke(Control,disableGlobalHotkeyRegister) = keystroke(Super,Rajveer-Mac-Mini,activeScreenOnly)
- this allows the original keystroke to perform on the server, akin to if we also hadkeystroke(Control,Server,activeScreenOnly)
Linux server specifics
On Linux, keystroke actions currently don't seem to work on the server at all. However, using
disableGlobalHotkeyRegister
at least allows us to achieve the same as in the above example (i.e. the server can perform the default keybind whilst clients have custom keybinds)keystroke(Left) = keystroke(Right)
- this works on Windows and macOS when focusing the server, but not Linuxkeystroke(Left) = keystroke(Left)
- this doesn't work on any server (but works on all when usingdisableGlobalHotkeyRegister
)keystroke(Left,disableGlobalHotkeyRegister) = keystroke(Right,Mac-Mini,activeScreenOnly)
- but at least this allows a custom hotkey onMac-Mini
whilst still allowing the default keystroke to perform on a server on any platformA real-world example
I want to control my Mac computers from my Windows machine, and want them to work with Windows keybinds (e.g. Ctrl+C to copy). On macOS I use Karabiner-Elements for this, but this doesn't work with Barrier. I now use the below configuration to achieve the same effect when running a Windows server:
Contributor Checklist:
doc/newsfragments
directory IF it is auser-visible change (and make sure to read the
README.md
in that directory)