Skip to content
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

Feature/dynamic menubar icon #43

Merged

Conversation

asvela
Copy link
Contributor

@asvela asvela commented Apr 5, 2020

Possible base for new feature for displaying the current CPU temperature rather than a static icon in the menubar (addressing feature request #42).

To do:

  • Option to display icon or temperature
  • (Option to choose CPU or GPU temperature)

Tested on macOS 10.14.6.

(Let me know if I should have done this differently than opening a pull request, I am not familiar with how to contribute)

@DanielStormApps
Copy link
Owner

Thank you for taking a stab at this @asvela !

I'll review the PR and leave some feedback. In its current state with the TODO's I wouldn't want to merge this in. Would you be ok with me taking this feature over?

@@ -658,15 +658,15 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = E5BK5K7RRN;
DEVELOPMENT_TEAM = HT8VTXFQ39;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to look into a way to disambiguate this so its not always changing 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I just should just not have committed the xcodeproj? As I did not do any other changes there than the version (I think)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’d work, but I don’t want to have to try to enforce that on every PR.

ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = fanny/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 2.1.0;
MARKETING_VERSION = 2.1.1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd want to version the project separately from a PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I was not sure about the conventions here, if you bounce it upon completing a new version or when you start adding things

@@ -19,15 +19,20 @@ class FNYStatusBar: NSStatusBar {
override init() {
super.init()
statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
applyStatusItemIcon()
statusItem?.button?.title = "Loading.."
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is necessary. Can you elaborate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure either, hehe! It does take those first x seconds of the refresh interval before the first number appears, but maybe the icon should rather be displayed during this time? At the same time this might be confusing; if you have a long refresh interval (60 sec) and change the setting governing if the temperature rather than the icon should be displayed, but then seemingly nothing changes for the first 60 secs and you wonder if the setting was really changed.


func updateStatusItem() {
let cpuTemperature = SMC.shared.cpuTemperatureAverage()
statusItem?.button?.title = cpuTemperature!.formattedTemperature(decimals: 0, useSpaceDelimiter: false)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can see the force unwrap ! causing issues here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not sure how this should be done, addressed it in 8461f4f with a possible fix

@asvela
Copy link
Contributor Author

asvela commented Apr 5, 2020

Thank you for taking a stab at this @asvela !

I'll review the PR and leave some feedback. In its current state with the TODO's I wouldn't want to merge this in. Would you be ok with me taking this feature over?

Sure, absolutely! I agree it is not ready to merge in quite yet, but was not sure how I would share it otherwise than making a pull request (if I should have done it differently please let me know).

As I said previously, I have no experience with this so please excuse the not so elegant way of doing it. Happy to assist if there are other things I could possibly do.

… Empty does not remove the menubar item, just makes it 'invisible'
@asvela
Copy link
Contributor Author

asvela commented Apr 6, 2020

Made some changes to add icon/temperature/nothing preference option:

icon
temperature

However, I am not sure how to remove/hide the menubar item all together. Currently it is just an empty narrow strip:
Screenshot 2020-04-06 14 44 27

The storyboard constraints were confusing, so they might need some revision too.

@vanthuanqs
Copy link

Thank guys, I was looking for this feature for a long time, hope it's going to live soon

@DanielStormApps
Copy link
Owner

Thank you for taking a stab at this @asvela !
I'll review the PR and leave some feedback. In its current state with the TODO's I wouldn't want to merge this in. Would you be ok with me taking this feature over?

Sure, absolutely! I agree it is not ready to merge in quite yet, but was not sure how I would share it otherwise than making a pull request (if I should have done it differently please let me know).

As I said previously, I have no experience with this so please excuse the not so elegant way of doing it. Happy to assist if there are other things I could possibly do.

A PR is the right way to share 👍

@DanielStormApps
Copy link
Owner

Made some changes to add icon/temperature/nothing preference option:

icon
temperature

However, I am not sure how to remove/hide the menubar item all together. Currently it is just an empty narrow strip:
Screenshot 2020-04-06 14 44 27

The storyboard constraints were confusing, so they might need some revision too.

Nice! Thank you!
I won’t have time until later this week to go over it all. Will keep ya posted 👍

DanielStormApps added a commit that referenced this pull request Apr 10, 2020
…updates. Update preference view controller constraints. Revert version to 2.1.0.
@DanielStormApps DanielStormApps merged commit f426793 into DanielStormApps:master Apr 10, 2020
@DanielStormApps
Copy link
Owner

@asvela Merged ✅

Made some changes on another branch: b352a3f

I removed the "hidden" menu bar option. This isn't something I'd like to support.
If you'd like to hide your menu bar icons take a look at Bartender: https://www.macbartender.com

v2.2.0 is ready for download and contains these new features.

Thank you for the PR! 👍

@asvela
Copy link
Contributor Author

asvela commented Apr 11, 2020

Thanks for including this!

I posted a little comment on considering removing the decimals (possibly also the space) from the menubar as they take up space and are not really adding reliable information.

Regarding

I removed the "hidden" menu bar option. This isn't something I'd like to support.

I just thought I'd mention this from Apple's Human interface guidelines:

Let people decide whether to enable your menu bar extra. Users, not apps, should choose when a menu bar extra is added to the menu bar. Typically, this is done by changing a setting in an app’s preferences window. To ensure discoverability, however, consider giving people the option of enabling the menu bar extra during setup.

It might be someone wants to use the nice widget but not the menubar icon. Relying on third party apps for hiding it is not ideal, and many programs include this feature of removing it (Dropbox, Alfred, Clipy are just some examples that came to mind). However, it seems the app needs some restructuring to do that properly, not just the cheesy way I did it, so it might be a lot of work for a niche feature.

@DanielStormApps
Copy link
Owner

Unfortunately there's no way around not having a menu bar icon. Today Extension widgets require that sandbox is enabled so the widget needs needs a "main" application to retrieve all the system values. The alternative would be having an application running in your dock at all times, which isn't better IMO. Setting the menu bar to an empty string with no icon will cause confusion.

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

Successfully merging this pull request may close these issues.

Feature request: Display CPU temperature in the statusbar
3 participants