jordanbaird / Ice

Powerful menu bar manager for macOS
https://icemenubar.app
GNU General Public License v3.0
10.26k stars 194 forks source link

[Bug]: Menu bar shapes didn't appear to work #47

Closed Xytronix closed 2 weeks ago

Xytronix commented 3 months ago

Check existing issues

Description

Shapes don't appear to work with the latest version. I do have tint and shadow activated so perhaps this has to do with it? In addition menu bar items are out of range to be accessed ( too many icons in the menu bar)

Steps to Reproduce

  1. Go to menu bar
  2. Assign shape

Ice Version

0.8.0

macOS Version

14.4.1

Screenshots

No response

jordanbaird commented 2 months ago

Could you post a screenshot of what it looks like? Even if it looks like nothing, it will still be helpful, as I can't reproduce it on my machine.

uncenter commented 2 months ago

I think I may have had a similar issue - restarted my computer to update (to Sonoma 14.4.1) and after the update completed the menubar was no longer split as configured. I originally thought maybe the update somehow broke it, but it looks like closing and reopening Ice did the trick to get the shape to apply again. Hope that helps.

TonioGela commented 1 month ago

I can confirm that on Sonoma 14.4.1 and Sonoma 14.5 with the Automatically Hidden Menu Bar Setting on, Shapes do not work as per the screenshot. image

I also noticed that the Hide application menus when showing menu bar items setting is not honoured (if not for ICE itself), so I wonder if it's due to a change in the MenuBar API.

I'll be glad to provide further help/info if necessary, feel free to ask

EDIT. Of course I reopened the app, rebooted, all the normal things you would do. Also my SIP is enabled.

jordanbaird commented 1 month ago

I just pushed out an update (0.9.0) a couple hours ago, could those in this thread that have this issue confirm whether it's still a problem after updating?

jordanbaird commented 1 month ago

@TonioGela When you say Automatically Hidden Menu Bar settings, do you mean the setting in the Control Center pane of macOS System Settings?

SCR-20240606-hmsc

Or the Automatically rehide setting in Ice?

SCR-20240606-hntd
TonioGela commented 1 month ago

@TonioGela When you say Automatically Hidden Menu Bar settings, do you mean the setting in the Control Center pane of macOS System Settings?

The one in macos System Settings. Funnily enough, disabling and re-enabling it made the menubar styling work again 🤔 (still using 0.8.0)

jordanbaird commented 1 month ago

@TonioGela Okay, yeah. I can reproduce this. I didn't take the automatically hiding menu bar into account when I implemented the appearance features. I'll need to figure out some way to check if the menu bar is visible and hide/show the appearance overlay accordingly.

TonioGela commented 1 month ago

@TonioGela Okay, yeah. I can reproduce this. I didn't take the automatically hiding menu bar into account when I implemented the appearance features. I'll need to figure out some way to check if the menu bar is visible and hide/show the appearance overlay accordingly.

Ah okay, makes sense. You need to check whether there's an os-level API that exposes that setting.

In any case, it's not affecting my user experience as I'm not using this feature. So don't worry about me ;)

TonioGela commented 1 month ago

@TonioGela Okay, yeah. I can reproduce this. I didn't take the automatically hiding menu bar into account when I implemented the appearance features. I'll need to figure out some way to check if the menu bar is visible and hide/show the appearance overlay accordingly.

And I think I found a way to programmatically tell it :D

defaults read NSGlobalDomain "_HIHideMenuBar"

it's either 0 or 1 accordingly.

[EDIT] There are 2 settings involved.

If you prompt a defaults read NSGlobalDomain | grep -i menu you'll see that these 2 settings change according to the specific hide and show mode.

AppleMenuBarVisibleInFullscreen = 0;
"_HIHideMenuBar" = 1;

The mappings are:

(0,1) => "Always"
(1,1) => "On Desktop Only"
(0,0) => "In Fullscreen Only"
(1,0) => "Never"

So I think you can read these 2 with defaults read NSGlobalDomain <prop>, do your thing (I assume it involves recording that piece of the screen to be able to tell the differences, and then reset them to the previous values (with defaults read NSGlobalDomain <prop> -int 0|1).

Truth to be told, you can also use this trick in case you need to update the data you use to compute the visual delta.

jordanbaird commented 1 month ago

My only concern there is the underscore, meaning it's a private API and could change in any macOS release. A reliable way (albeit more expensive) is to use the CGWindowList API to get a list of onscreen windows and filter out the one whose layer is kCGMainMenuWindowLevel. But I worry that might be too computationally expensive, as we'd have to do it repeatedly. I think I'm going to look into the Accessibility API to see if there's a way I can observe the menu bar window frame, but I may use the defaults method as a backup.

EDIT: OR we could use the defaults method as the primary and use either the CGWindowList or Accessibility API as the backup...