0

Context:

When I select "Dark" or "Light" in Ubuntu's Settings > Appearance > Style, gedit detects this change and switches its internal them to Yaru Dark or Yaru Light appropriately. I really like this feature! But I would prefer that gedit use the Builder and Builder Dark themes (which interact better with markdown syntax highlighting for my purposes) instead of Yaru.

Question:

Is it possible to configure gedit such that, when it gets the message from Ubuntu/GNOME to switch to a dark or light style, it will choose a specific theme for either instead of the default Yaru variant?

Related:

I found this answer on using gsettings to switch GNOME's theme interesting, as I'd love to be able to toggle dark/light mode from within gedit via an external tool hotkey. I noticed that switching the desktop theme this way does not trigger gedit to switch its internal theme, nor does it change whether Dark or Light is selected in Settings > Appearance > Style.

1 Answers1

0

Here's a workaround, adapted from this answer on command line dark/light toggling. I now just run this script, via a custom keyboard shortcut, in order to switch between dark and light modes.

#!/usr/bin/env sh
set -euo

if test "$(gsettings get org.gnome.desktop.interface color-scheme)" = "'prefer-light'"; then gsettings set org.gnome.desktop.interface color-scheme prefer-dark gsettings set org.gnome.desktop.interface gtk-theme 'Yaru-dark' sleep 1 gsettings set org.gnome.gedit.preferences.editor scheme 'builder-dark' else gsettings set org.gnome.desktop.interface color-scheme prefer-light gsettings set org.gnome.desktop.interface gtk-theme 'Yaru' sleep 1 gsettings set org.gnome.gedit.preferences.editor scheme 'builder' fi

The sleep 1 is needed because, only when the Settings application is open, Ubuntu/GNOME will animate the switch between GTK themes – so whatever handler gedit has to catch that theme change will execute after a slight delay.