Skip to content

Conversation

@felix-andreas
Copy link
Member

@felix-andreas felix-andreas commented Jul 18, 2019

Fixes elementary/terminal#319

TL;DR: A simple plugin to bind keyboard shortcuts to open/focus specific applications.

⚠️ Disclaimer:
Remove this plugin when switching back to master:
rm /usr/lib/x86_64-linux-gnu/gala/plugins/libgala-appshortcuts.so
Otherwise you cannot login again!

Motivation

With increasing number of different windows (often multiple instances of the same application), I always feel (in all major desktops, not only elementary) not being able to efficiently switch focus between them anymore.
As 95% of the time I only use 5 different applications, I always wanted a shortcut to directly switch focus to one of them. Alt+Esc and Alt+Tab are great for the most recent applications but get tedious for applications more than 3 key presses away.

The idea is to introduce the possibility to bind a keyboard shortcut to a single application. Pressing this shortcut would focus this application. Pressing it multiple times would toggle focus between the different windows of this application. In other words: an application-specific Alt-Tab shortcut.

Behavior

The Application shortcut behaves in that way that if ..

  • Case 1: ... the application is not running, it opens a new instance.
  • Case 2: ... the application is running but is not focused, it focuses the instance with highest z-index.
  • Case 3: ... the application is running and has focus, it focuses another instance (lowest z-index).

The most important applications (like files, terminal, browser, ...) get all bond to a combination of Super+Key.

Additionally Super+Ctrl+Key will always open a new window of the application regardless if another instance is already running. (not implemented yet)

In this first implementation the default applications are bind to the following shortcuts:

  • Text Editor - Super+E
  • File Manger - Super+M
  • Web Browser - Super+B
  • Terminal - Super+T

Productivity/Workflow

This feature would imo increase the productivity for different scenarios:

  • Quickly show/hide a browser or terminal to do a simple web search or to quickly execute a command.
  • Toggling focus between two windows of a text-editor or terminal.
  • Navigating between many different windows especially when dealing with multiple workspaces.

Also I think this feature would not only be useful for a keyboard-driven workflows as it also can reduce the mouse movement in some cases. For example, if the mouse is on top of the screen and one wants to do a web search, one has to move the cursor down to plank and than again up to click the search bar. With the Application-Shortcut one has to press the shortcut and then move the cursor only a short distance to the search bar.

I also recorded a simple Demo video to showcase the workflow for these cases.

Consistency

As it is already possible to open some applications with a shortcut, this feature would simple extend this functionality by the focusing/toggling component. The current behavior which always opens a new window would get bound to Super+Ctrl+Key.

This feature would also be consistent with the current behavior of plank, where a left-click opens a new window when the application is not running and focuses the highest window if the application is running. Also in plank Ctrl-Click opens a new instance of the application regardless if another instance is already running and the toggling behavior between windows of the same application is achieved by scrolling over an item.

This feature could made be more consistent to Alt+Tab by allowing Super+Shift+Key to toggle backwards.

This PR

This PR is only a first implementation to demonstrate this feature. It is not ready for review, but suggestions are welcome!

If the idea gets accepted I would additionally implement, Shift to toggle backwards, Ctrl to always open a new window and maybe make the code a bit more efficient.

possible to toggle focus for builtin applications:

- terminal: super+t
- files   : super+m
- epiphany: super+b
- code    : super+e

compare app_id with wm_class to filter applications
@jlnr
Copy link
Contributor

jlnr commented Jul 18, 2019

I agree with the use case and I like the idea of toggling through windows. But in terms of shortcuts, I prefer the way this is handled in Ubuntu (I think starting in Unity?): the first dock icon is always cmd+1, the second is cmd+2, etc. That makes shortcuts workflow-agnostic and even easier to customize. And you can assist the user by showing tiny numbers in the dock while cmd is held down.

cmd+n is already bound to workspace switching in elementary; maybe cmd+F1, cmd+F2, ... would work?

(Changing cmd+T to open my existing terminal rather than opening new ones would be ❤️)

@felix-andreas
Copy link
Member Author

felix-andreas commented Jul 18, 2019

Thanks for the feedback! Would it be crazy to allow both? Super+Key for the favorite applications and Super+FKey for the current applications.

Some reasons why I think the "dock-position" approach alone would not be enough:

  • not able launch applications which are not in the dock
  • if the dock is not visible Super+F3 is harder to remember than Super+T
  • if you reorder your dock, you will loose the muscle memory

The idea with the tiny indicators sounds nice, but I could imagine it could be irritating when pressing other shortcuts. Maybe one could implement these number-indicators in the Alt-Tab view or window overview?

Could you maybe explain why you think the "dock-position" approach would be easier to customize? All the keyboard shortcuts would also be customize-able through settings. Also the shortcuts already use the current default applications. You could even change these to manually Super+FKey so the will visually match order of the dock...

Also the

  • Text Editor - Super+E
  • File Manger - Super+M
  • Web Browser - Super+B
  • Terminal - Super+T

shortcuts were just for demonstration purposes. I personally wouldn't mind to change them (or even deactivated them by default) as long as I can change them through settings.

@jlnr
Copy link
Contributor

jlnr commented Jul 18, 2019

I don't think that everyone lives in the same set of apps. I don't jump to my default editor (Code) very often, instead I'd love to have shortcuts for Android Studio and gitg. With the "dock position" approach, I only need to make sure they are among the first twelve dock icons, and my shortcut setup is done. That's the sort of "customization" I was thinking of.

But sorry, you are of course right that we could totally have both. I'll open a separate ticket after some more consideration.

By the way, what do you think about adding case 4: when the app only has one window and it is already focused, then pressing the shortcut again hides the window -- similar to clicking a Plank icon twice. That could be great to bring up an app and dismiss it with minimal finger movements, just to check a log in the Terminal etc.

@felix-andreas
Copy link
Member Author

felix-andreas commented Jul 19, 2019

I don't think that everyone lives in the same set of apps. I don't jump to my default editor (Code) very often, instead I'd love to have shortcuts for Android Studio and gitg. With the "dock position" approach, I only need to make sure they are among the first twelve dock icons, and my shortcut setup is done. That's the sort of "customization" I was thinking of.

That is a good point, I will in addition to the default applications introduce an option to bind this shortcut directly to a given .desktop file. But this will also need a dedicated view in the keyboard-switchboard-plug where one could chose favorite applications to bind.

By the way, what do you think about adding case 4: when the app only has one window and it is already focused, then pressing the shortcut again hides the window -- similar to clicking a Plank icon twice. That could be great to bring up an app and dismiss it with minimal finger movements, just to check a log in the Terminal etc.

This would not be difficult to implement, but a fourth case could also make this feature more confusing for a normal user. BTW, You can already achieve the same behavior by focusing the application with Super+key and than switch back with Alt+Esc or hide with Super+H. But I am open to implement that ...

Should in this fourth case the application be hidden or just moved back to its last z position?

@felix-andreas felix-andreas changed the title [Feature] Quick switch [Feature] Better Application shortcuts Aug 11, 2019
@felix-andreas
Copy link
Member Author

felix-andreas commented Aug 11, 2019

@jlnr I have now added a possibility to bind custom applications and I also did a first implementation (elementary/settings-keyboard#233) for the settings-keyboard plug. It would be nice to get some feedback!

When switching back to master don't forget to remove the plugin:

rm /usr/lib/x86_64-linux-gnu/gala/plugins/libgala-appshortcuts.so

applications-menu

@Serkan80
Copy link

I also have the urgent need for a shortcut to switch between windows of the same app. I have the same frustrations as the topic opener.

If Im not wrong, you can do this in OSX by pressing super+’.

Anyways lets not discuss which keycombinations we should use for this functionallity. Just take a sensible default and give the option to change it in the settings.

@felix-andreas felix-andreas changed the title [Feature] Better Application shortcuts [Feature] Introduce shortcuts to focus/open applications Mar 4, 2020
@felix-andreas felix-andreas changed the title [Feature] Introduce shortcuts to focus/open applications Introduce shortcuts to focus/open applications Jul 12, 2020
@felix-andreas
Copy link
Member Author

felix-andreas commented Jul 12, 2020

Last commit also fixes #536

Edit
Just noticed that #536 is already implemented in mutter. It is accessible via AltF6. So it is pointless to re-implement it here 🙄.

@felix-andreas
Copy link
Member Author

felix-andreas commented Apr 28, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System-wide Hot key to open/close the existing Terminal

4 participants