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

auto dark mode #1643

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

auto dark mode #1643

wants to merge 1 commit into from

Conversation

triosi
Copy link

@triosi triosi commented Feb 20, 2025

I’ve added a "System Default" theme option that reads the system theme and applies it to Sparrow (switching between Light and Dark) at startup. This change ensures Sparrow launches with the same theme as the user’s system preference.

Changes Made:

  • Added a detectSystemTheme method to identify the system theme.
  • Implemented isMacDarkMode to check the AppleInterfaceStyle setting on macOS.
  • Modified the startup logic to apply the system theme when "System Default" is selected.

Limitations:

  • Currently, this feature only works on macOS. I don’t have test environments for Linux or Windows, so I haven’t implemented theme detection for those platforms yet.
  • I didn’t add dynamic theme switching (i.e., updating the app’s theme when the system theme changes while the app is running). Implementing this might require polling the system theme continuously, which could be resource-intensive. I’m unsure if the added complexity is worth it and would appreciate feedback on this.
  • I wasn’t able to apply dark mode to the welcome screen during its initial launch, so it remains in light mode even when the system theme is dark.

Future Steps:

  • If this PR is deemed useful, I’m willing to extend support to Windows and Linux. I can write the necessary code and set up virtual environments to test them.

@craigraw
Copy link
Collaborator

Thanks for the suggestion. A little nitpick that the OsType class should be used instead of System.getProperty("os.name"). Another is that isMacDarkMode should catch Throwable, as any failure will prevent app startup.

On a broader scope, I've taken a look at https://github.com/Dansoftowner/jSystemThemeDetector and it seems there's more than one approach. I'm not particularly keen to add all the dependencies that project has for such a simple function, but it's worth considering the techniques used there.

I think I'd want to put in more work into the dark theme before merging this. Specifically, there are images that require SVG alternatives so they can be properly colour inverted in dark mode.

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

Successfully merging this pull request may close these issues.

2 participants