argos
argos copied to clipboard
Add keyboard shortcuts
First of all, thank you very much for this extension. It is exactly what I was looking for without knowing it :)
What I am missing most is to use keyboard shortcuts for pressing items in the dropdown menu.
I guess it might be problematic to add keyboard shortcuts directly because of conflicts. In this case I would suggest using a master hotkey (e.g. Super+Alt+a) followed by a single key or key combination specified in the item line (e.g. hotkey=q or hotkey=<ctrl>+s).
Short answer: This isn't possible in GNOME Shell.
Long answer: This is possible in GNOME Shell, but only with a hack that is so breathtakingly ugly that I just can't decide whether I want it in the code. See this for details.
I dont know how GNOME Shell really works, but wouldn't my suggested approach work around the problem?
So if you have one dedicated master hotkey in Argos, it would start an overlay of some kind in foreground (visible or not) which takes the next keystroke and maps it to the script items.
I would argue that this is the safer approach anyway. Otherwise if you download scripts made by other people with random hotkeys in it, it would pollute the GNOME hotkeys. This way conflicts can only happen between argos scripts.
That would probably work, but I'm not going to implement it that way. Two-level shortcuts break standard GNOME UX. No other shortcut in GNOME or any modern GNOME app works that way. It's clear that the correct UX is to be able to assign any shortcut to any item without prefix namespacing. Nobody really wants a shortcut like Super+Alt+A Ctrl+S.
Shortcut conflicts, on the other hand, are something that I'm not the least worried about. Given that the user sets up those shortcuts, conflicts are the user's responsibility to know about and avoid. GNOME already has configurable shortcuts for window management and such. They are not prefixed, and if modified can conflict with anything. If a conflict arises, the user just edits the script and that's it.
To be clear, I really want this feature, but only if it can be implemented cleanly without artificial restrictions like not being able to assign any shortcut you want. Unfortunately, an omission in the GNOME Shell API stands in the way. Argos is not the only extension hampered by this problem. The solution is to add the missing API to GNOME Shell and then use it in Argos.
Personally I dont mind using two-prompt shortcuts, I am using it every day with tmux (and it doesnt need to be a modifier for the second key), but I understand the design decision. And of course direct shortcuts are better.
Lets hope Gnome will improve here :)
Amazingly, someone seems to have found a way to get Mutter to bind keys directly: https://superuser.com/a/1182899
This might mean that adding this feature is now possible after all!
Nice extension! In older versions of gnome-shell (< 3.8) i had an extension that did exactly that. Maybe you can use keybinding code. The same code is used in my put-window extension that works perfectly fine with 3.30 with x11 and wayland.
_addKeyBinding: function() {
let key = Utils.SIMPLE_MENU_KEY_BINDING;
let handler = Lang.bind(this, function(){
this._myPanelButton.menu.toggle();
this._myPanelButton.focusFirstElement();
});
if (Main.wm.addKeybinding && Shell.KeyBindingMode) { // introduced in 3.7.5
// Shell.KeyBindingMode.NORMAL | Shell.KeyBindingMode.MESSAGE_TRAY,
Main.wm.addKeybinding(key,
Utils.getSettingsObject(), Meta.KeyBindingFlags.NONE,
Shell.KeyBindingMode.NORMAL,
handler
);
} else {
global.display.add_keybinding(
key,
Utils.getSettingsObject(),
Meta.KeyBindingFlags.NONE,
handler
);
}
},
Are there any updates regarding this?
I think there is an API for this now: https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/windowManager.js#L1099
For example, here is where gTile uses it: https://github.com/gTile/gTile/blob/master/hotkeys.ts#L31