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

Use color scheme based on OS system dark/light mode preferences #1233

Merged
merged 8 commits into from
Oct 10, 2023

Conversation

christianparpart
Copy link
Member

@christianparpart christianparpart commented Oct 6, 2023

Closes #604

Checklist

  • get dark/light theme mode events on Linux
  • get dark/light theme mode events on MacOS
  • get dark/light theme mode events on Windows (how)
  • config: extend config to allow specifying dark and light mode themes (then the system setting will decide what to chose from) or just one and then this is always used
  • apply color scheme based on that.
  • propagate dark/light mode changes to the app (VT extension to query state and get realtime notifications on state changes)
  • reflect changes in documentation
  • changelog entry added to metainfo.xml
2023-10-07.23-02-14.mp4

@github-actions github-actions bot added the frontend Contour Terminal Emulator (GUI frontend) label Oct 6, 2023
Copy link
Member

@Yaraslaut Yaraslaut left a comment

Choose a reason for hiding this comment

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

Documentation is missing :)

src/contour/ContourGuiApp.cpp Outdated Show resolved Hide resolved
src/contour/ContourGuiApp.cpp Outdated Show resolved Hide resolved
src/contour/contour.yml Outdated Show resolved Hide resolved
@christianparpart
Copy link
Member Author

Documentation is missing :)

@Yaraslaut I sadly didn't decide yet how the configuration should look like. What you see is my proposal. But if you have an idea on how it could be done better, I'm absolutely open - then of course we must document that within this PR as well :)

@christianparpart christianparpart force-pushed the feature/dark-and-light-mode-schemes branch 2 times, most recently from 74881d9 to 520d80a Compare October 7, 2023 21:21
@github-actions github-actions bot added the VT: Backend Virtual Terminal Backend (libterminal API) label Oct 7, 2023
@christianparpart
Copy link
Member Author

MacOS bits as provided by @uspasojevic96:

#import <Cocoa/Cocoa.h>
- (BOOL)isDarkMode {
    NSAppearance *currentAppearance = [NSAppearance currentAppearance];
    if (currentAppearance) {
        // Check if the current appearance is dark
        if (@available(macOS 10.14, *)) {
            return [currentAppearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameDarkAqua]] == NSAppearanceNameDarkAqua;
        }
    }
    
    // Default to light mode if appearance cannot be determined
    return NO;
}

For event subscription:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appearanceDidChange:) name:NSAppearanceDidChangeNotification object:nil];

I will probably need some help to clue that into the code base, as I've never touched ObjC/++ just yet :|

@christianparpart christianparpart force-pushed the feature/dark-and-light-mode-schemes branch 2 times, most recently from 87cd413 to 6b0d99c Compare October 7, 2023 22:27
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Oct 7, 2023
@christianparpart christianparpart force-pushed the feature/dark-and-light-mode-schemes branch 8 times, most recently from 3345f37 to cfa4e5c Compare October 10, 2023 09:51
@christianparpart christianparpart force-pushed the feature/dark-and-light-mode-schemes branch from cfa4e5c to f6ae50b Compare October 10, 2023 09:54
@christianparpart christianparpart marked this pull request as ready for review October 10, 2023 09:54
@christianparpart christianparpart force-pushed the feature/dark-and-light-mode-schemes branch 3 times, most recently from bdc4742 to d72648c Compare October 10, 2023 10:02
@christianparpart christianparpart changed the title WIP: Use color scheme based on OS system dark/light mode preferences Use color scheme based on OS system dark/light mode preferences Oct 10, 2023
@christianparpart christianparpart force-pushed the feature/dark-and-light-mode-schemes branch 4 times, most recently from 63e415e to 66bb267 Compare October 10, 2023 10:37
@christianparpart christianparpart force-pushed the feature/dark-and-light-mode-schemes branch 2 times, most recently from abb0e18 to 35aff73 Compare October 10, 2023 11:06
Signed-off-by: Christian Parpart <christian@parpart.family>
Signed-off-by: Christian Parpart <christian@parpart.family>
Signed-off-by: Christian Parpart <christian@parpart.family>
Signed-off-by: Christian Parpart <christian@parpart.family>
Signed-off-by: Christian Parpart <christian@parpart.family>
…icit and unsolicited) and adds DEC mode 2031 to enable/disable unsolicited reports of that

Signed-off-by: Christian Parpart <christian@parpart.family>
@christianparpart christianparpart force-pushed the feature/dark-and-light-mode-schemes branch from 35aff73 to 60781dc Compare October 10, 2023 11:08
@christianparpart christianparpart merged commit 7d7fa71 into master Oct 10, 2023
63 checks passed
@christianparpart christianparpart deleted the feature/dark-and-light-mode-schemes branch October 10, 2023 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation frontend Contour Terminal Emulator (GUI frontend) VT: Backend Virtual Terminal Backend (libterminal API)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

default config's color scheme should respect dark/light mode OS settings
2 participants