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

Add an event for macOS appearance change #766

Closed
L-TChen opened this issue Oct 31, 2018 · 7 comments

Comments

@L-TChen
Copy link
Contributor

commented Oct 31, 2018

As macOS 10.14 supports dark mode, it would be very useful to have an event for the appearance change and also a variable for the current appearance. Some snippet code for detecting the current appearance can be found here. The official document suggests

Apps can also use key-value observing (KVO) to monitor changes to the effectiveAppearance property of a view or window and make custom changes. (see here)

I wrote a simple script to change the appearance by running some AppleScript and set the option background accordingly. It would be ideal to have the change of option fired whenever the system changes its appearance.

Or, please suggest where I can put the code. I am not familiar with Obj-C, though.

@ychin ychin added the 10.14 Mojave label Nov 19, 2018
@L-TChen L-TChen changed the title Feature Request: Add an event for macOS appearance change Add an event for macOS appearance change Jul 24, 2019
@L-TChen

This comment has been minimized.

Copy link
Contributor Author

commented Jul 26, 2019

While trying to implement this myself I realise this feature should be added to Vim itself instead of MacVim, because even in a terminal emulator Vim may use this change of appearance to change background and colour theme as well.

Hence, I am closing this issue now.

@L-TChen L-TChen closed this Jul 26, 2019
@ychin

This comment has been minimized.

Copy link
Member

commented Jul 27, 2019

Hmm, I was thinking about ways to add this in MacVim and I'm not sure if Vim would add something so platform specific like this. If you add an issue to Vim please cross-reference it here.

@eirnym

This comment has been minimized.

Copy link
Contributor

commented Jul 27, 2019

@L-TChen , thank you for the improvement.
I'm not sure about adding this feature to the Vim core. In Terminal.app you have independent settings, even they're defaults.

@L-TChen

This comment has been minimized.

Copy link
Contributor Author

commented Jul 27, 2019

Hi, thanks for your comments.

The basic idea is to have (optionally) a global variable, say, g:os_dark_mode and an event emitted when the OS switches its appearance, so the users can hook a vim function to act accordingly. It should not touch background by default.

It was platform specific until the dark mode support is added in Windows 10. I am not sure about linux, although it appears that GNOME has a similar setting.

In some terminal emulators like iTerm2, there is a way to change profile theme based on system-wide setting (https://gitlab.com/gnachman/iterm2/issues/6764).

So, in my opinion, it makes sense to add this functionality to Vim instead of MacVim.

@L-TChen

This comment has been minimized.

Copy link
Contributor Author

commented Jul 29, 2019

@L-TChen , thank you for the improvement.
I'm not sure about adding this feature to the Vim core. In Terminal.app you have independent settings, even they're defaults.

Aha, I see your point here. Right, an app may have its own appearance setting different than the global setting. So, getting the setting from the OS (e.g., via defaults) may give an incorrect behaviour.

The core Vim should get the appearance setting from the GUI frontend or the terminal emulator where Vim is running. So, the MacVim frontend does need to add this directly to trigger the proposed event. Does that make sense?

@L-TChen L-TChen reopened this Jul 29, 2019
@eirnym

This comment has been minimized.

Copy link
Contributor

commented Jul 30, 2019

This event by nature goes from GUI subsystem to optionally trigger the background check. The processing of this event (setting background option to dark or light, I assume, may be some additional triggers to change window decorations in GUI) could be in core, but triggered by GUI.

I would be personally fine if a GUI event will trigger the change only by my explicit setting if I want to do it, as I and most people I know prefer personally exact themes and colours for specific programs despite the fact they could use light or dark GUI in system.

@L-TChen

This comment has been minimized.

Copy link
Contributor Author

commented Jul 30, 2019

Yes. That’s exactly what I am implementing now.

I am working half way through it. I will open a draft PR later.

@L-TChen L-TChen referenced this issue Jul 30, 2019
3 of 3 tasks complete
L-TChen added a commit to L-TChen/macvim that referenced this issue Oct 6, 2019
@ychin ychin closed this in 5730262 Oct 8, 2019
ychin added a commit that referenced this issue Oct 8, 2019
[fix #766] Add an event for OS appearance change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.