How to Stop macOS Menu Bar Animation on a Secondary Screen

Hello everyone,

I'm working on a macOS application and encountering an issue related to multi-screen setups.

My application includes an animation in the menu bar, and it works perfectly on the primary screen. However, I want this animation to stop or not appear when the app is being used on a secondary monitor(non-focused monitor).

(for cpu related problem, when it's 3 monitor -> x3 cpu with x3 animation objects)

I've tried a few approaches to detect when the application is being used on a secondary screen and then stop the animation, but so far, I haven't had any success.

The main challenge seems to be accurately determining the screen where the app is actively being used and controlling the animation accordingly.

Has anyone faced a similar issue or have suggestions on how to effectively stop or prevent the menu bar animation from running on a secondary screen? Any guidance or insights would be greatly appreciated.

Thank you in advance for your help!

To solve this problem, I tried to implement logic to have multiple instances of the menu bar (with animations) recognize new monitors and assign them, but it didn't seem possible to have multiple instances per external screen in a single NSMenuItem, so I stopped.

How to Stop macOS Menu Bar Animation on a Secondary Screen
 
 
Q