Switching between dark/light modes and theme at the same time

What I’m trying to do

Find a way of switching between dark and light mode and switching the associated theme at the same time.
For example, for dark mode I prefer to use the Blackbird theme.
For light mode, I love the Primary theme.

Things I have tried

Creating a QuickAdd plugin macro
Creating a Commander plugin macro

I end up with a situation where a macro can bring up the theme selection dialog but then you need to pick the theme manually anyway.

Interesting.
There’s the theme design utilities plugin which allows to toggle between light and dark mode. I never understood why Obsidian adds two buttons to switch theme mode instead to add a simple toggle for the user interface.

However, to switch themes and theme mode at the same time, you’d need a plugin.

I’m trying to write a plugin doing this. In essence, settings to connect two different themes to Dark and Light mode. Then listening to dark/light mode changes to do the corresponding theme change.

Right now, I’m stuck at how change the theme in Obsidian from Typescript. Is there even an API for that? I’m looking at the theme switcher plugin GitHub - kenset/obsidian-theme-picker as an inspiration but I’m unable to find an API that actually does the switch in Obsidian.

Unluckily I don’t know typescript, (maybe in future).
My advice is, you could try to study some plugins with similar features.

No worries. I’ve found it in the meantime by reading the full sources, not just main.ts. Thanks for your patience :slight_smile:

this.app.customCss.setTheme(themeName);

OK, so I uploaded a first version here. I discovered a feature interaction with Obsidian’s Appearance dialog. If you pick two different themes, switching between Light/Dark in the “Base color scheme” drop down in fact changes the theme, though the “Themes” dropdown does not reflect the change. In the example, you can see the Primary theme and the “Themes” dropdown saying Blackbird.

I don’t know if there is a way of invalidating the current settings modal. Anyway, I’ll try doing a release and see if this is acceptable as a plugin contribution :slight_smile:

There are three commands built in for this in the command pallet (ctrl-p or cmd-p) and hotkeys can be assigned to make them instantaneous:

  • Change theme - offers a list of installed themes
  • Use dark mode
  • Use light mode

Yes, that’s what I’ve been using. Personally, I found it clunky

To be honest, I didn’t try your plugin yet.

would it be possible to have a hours and minutes input field in your plugin preferences to activate automatically light or dark mode? This would complete your plugin, imo.

I believe the Day and Night plugin might be what you’re looking for: GitHub - CyberT17/obsidian-day-and-night: An Obsidian plugin to automatically switch between day and night themes based on a set schedule

Haven’t tried it myself; your mileage might vary.

True, I know that plugin. So I used the wording “complete”, as your plugin adds some variety.

There are so many plugins out there that do just one tiny thing, I avoid them. Already important plugins pile up.