-
-
Notifications
You must be signed in to change notification settings - Fork 840
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
Add prev_application companion to the new open_application #4011
Comments
Sending Command+Tab is probably the easiest method. Alternatively, you could control it using a shell_command and |
Command+Tab wouldn't work as it would switch to another window of the same app if the 2nd window is the most recent one, then there is this complication that the appswitcher stays opened until you release the from modifier since you're sending to as modifiers, not a command. Not sure I understand the |
This meant that you would manage the history with a shell script while using the open command to switch to the appropriate application. |
I don't see why I'd need to do the error-prone keeping of history: All I need is to "deactivate" the current app, so change its "Z" order from top to top-1 Karabiner-Elements already has some of that info, it's used in the frontmost app condition? |
I see, that's interesting. I had thought the open_application history alone wouldn't be enough, but using the frontmost_application history does seem like it could work. I'll give it a try and see how it works. |
The history might not be enough since there is a chance something else will close an app present in history (or maybe if it's launched hidden it gets to the list of apps, but not to your history of apps that have been at the front). But from some brief searching it seems macOS is rather deficient here: there is no simple way to get a list of apps in order, e.g., this seems to work, but only within the current space So this API would mostly be useful at startup when KE has not seen any history yet, but later on it seems that tracking history which KE already does is indeed the only approach (and given that KE is usually launched at startup, that's a very minor issue) |
I added Note: Applications opened before Karabiner-Elements started are omitted. |
After some testing: it seems to work with just one bug - when you hit the same shortcut twice quickly, you don't end up at the app you've started with (though it works in Keyboard Maestro), guess either the list is not updated quick enough or maybe the second key doesn't wait till the list is updated or something else And maybe the following could be a more useful example for the new command's docs: toggling your file manager with the same key ⇪d (though the part of assigning 4 modifiers to ⇪ isn't shown here and could be linked to another part of the docs) {"description" : "Toggle an app with a single keybind ✦d: focus (open if no app running) / unfocus (switch to the previously opened app) (✦key=⇧⎈⎇⌘, can be assigned to ⇪)",
"manipulators" : [
{"from":{"key_code":"d","modifiers":{"mandatory":["left_command","left_control","left_option","left_shift"]}},
"to":[{"software_function":{"open_application":{"bundle_identifier":"com.apple.finder"}}}],
"conditions":[{"type":"frontmost_application_unless","bundle_identifiers":["^com\\.apple\\.finder$"]}],
"type":"basic"}
,
{"from":{"key_code":"d","modifiers":{"mandatory":["left_command","left_control","left_option","left_shift"]}},
"to":[{"software_function":{"open_application":{"history_index":1}}}],
"conditions":[{"type":"frontmost_application_if","bundle_identifiers":["^com\\.apple\\.finder$"]}],
"type":"basic"}
]
}, |
There is now an action to open an app open_application, so it would be great to also have a companion action to "undo" it so that you can toggle the same app with one conditional shortcut.
This
prev_application
action should the bring the previously focused app into focusThe text was updated successfully, but these errors were encountered: