billziss-gh / EnergyBar

Supercharge your Mac's Touch Bar.
GNU General Public License v3.0
749 stars 34 forks source link

Implementation of system control tray option #35

Open xiamaz opened 5 years ago

xiamaz commented 5 years ago

Add an touchbar option to show the system controls of the normal touchbar.

This option adds an energybar button to the system controls, which can be used to expand the energybar into the application space of the touchbar.

This way it is possible to use the system provided control button and offers a quick way to show the native touchbar controls.

ghost commented 5 years ago

I am fairly new to GitHub and was wondering if you could show me how to implement this, if implement is the right word. Thanks in advance 😊

xiamaz commented 5 years ago

I am fairly new to GitHub and was wondering if you could show me how to implement this, if implement is the right word. Thanks in advance 😊

@ninjien You can refer to this example project for a very simple example: https://github.com/a2/touch-baer

Essentially you create a widget, which will be shown on the touchbar by utilizing DFRFoundation private APIs. This process is fairly limited, as you can only show one additional button in the system controls. (This is also used by programs such as Quicktime or XCode debugger)

billziss-gh commented 5 years ago

@xiamaz thanks for the PR and I apologize for not being able to check it out earlier.

Overall I like the idea and I think we should incorporate it. However I found a some usability issues that I think we have to discuss and address first.

The main problem is that it is possible to check "Show system controls" and then close the EnergyBar window. Because EnergyBar is an LSUIElement application it is not easy to open the EnergyBar window again and uncheck "Show system controls".

PS: I only did some usability testing and have not reviewed the code. However I noticed in passing what appears to be a problem and will add a review comment after this message

xiamaz commented 5 years ago

@xiamaz thanks for the PR and I apologize for not being able to check it out earlier.

Thanks for the reply. I want to continue working on the PR, if there are good ways to overcome the usability issues.

Overall I like the idea and I think we should incorporate it. However I found a some usability issues that I think we have to discuss and address first.

The main problem is that it is possible to check "Show system controls" and then close the EnergyBar window. Because EnergyBar is an LSUIElement application it is not easy to open the EnergyBar window again and uncheck "Show system controls".

* The obvious way is to rerun EnergyBar, which shows the main window again (via `applicationShouldHandleReopen:hasVisibleWindows:`). While this works the average user may not think of it. (I am the project's original author and I was actually puzzled for a minute on how to get back the window while testing.)

Yes, I always just relaunched the EnergyBar app. If this could be blocked by some settings. I would suggest adding the ability to show Energybar settings by long-pressing the control tray button.

Still the current setting of long-pressing the date seems also to be an issue, if the user is not enabling this specific widget.

* I like the idea of adding a button to the Control Strip to bring back the EnergyBar. There are however a couple of problems with this approach:

  * The user may not have the Control Strip enabled in System Preferences | Keyboard. For example, in my system I have this always set to "Expanded Control Strip", because this makes EnergyBar customization easiest and because I never use the App Controls.

I only implemented it because I prefer the system controls, since otherwise we would need to reimplement all system control functionality in energybar, eg a IME switcher is currently missing.

  * Even when the Control Strip is enabled in System Preferences | Keyboard, the button displays the EnergyBar together with the Control Strip. IMO this has problems and would recommend that we simply bring the EnergyBar back "on top" in this case.

I would like to keep both, since I like having access to system controls directly. Maybe we should add this as a option?

* I have not researched why, but it is possible to get 2 esc buttons with this PR.

This probably because you had an esc widget enabled. If you are in the Energybar app the outer close button might be shown as another esc button.

PS: I only did some usability testing and have not reviewed the code. However I noticed in passing what appears to be a problem and will add a review comment after this message

I will update that.

xiamaz commented 5 years ago

I have rebased against the current version. Are you still considering this PR or have some suggestions?