From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= <mail@3v1n0.net>
Date: Tue, 5 Apr 2022 16:00:46 +0200
Subject: style-manager: Support Yaru accent colors

Generate the libadwaita color schemes using Yaru accent colors.
Then, when the Yaru theme is used in the system, use the generated
variant instead of the default one.
Also the yaru colors palette is used in such case.

No theme changes are applied, only the accent color is now matching
the yaru ones.

Forwarded: not-needed
---
 meson_options.txt                                |   4 +
 src/adw-settings-private.h                       |   2 +
 src/adw-settings.c                               | 195 +++++++++++++++++++++++
 src/adw-style-manager.c                          |  43 ++++-
 src/stylesheet/_defaults.scss                    |   7 +-
 src/stylesheet/_palette-yaru.scss                |  97 +++++++++++
 src/stylesheet/adwaita-stylesheet.gresources.xml |   1 +
 src/stylesheet/meson.build                       |  82 +++++++++-
 src/stylesheet/yaru_accent_colors.scss           |  39 +++++
 9 files changed, 459 insertions(+), 11 deletions(-)
 create mode 100644 src/stylesheet/_palette-yaru.scss
 create mode 100644 src/stylesheet/yaru_accent_colors.scss

diff --git a/meson_options.txt b/meson_options.txt
index b95d0ae..2ef9779 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -20,3 +20,7 @@ option('tests',
 option('examples',
        type: 'boolean', value: true,
        description: 'Build and install the examples and demo applications (currently not built for MSVC builds)')
+
+option('yaru-accent-colors',
+       type: 'boolean', value: true,
+       description: 'Mimic Yaru accent colors')
diff --git a/src/adw-settings-private.h b/src/adw-settings-private.h
index bab0962..87ebea6 100644
--- a/src/adw-settings-private.h
+++ b/src/adw-settings-private.h
@@ -56,4 +56,6 @@ ADW_AVAILABLE_IN_ALL
 void adw_settings_override_high_contrast (AdwSettings *self,
                                           gboolean     high_contrast);
 
+const char *adw_settings_get_yaru_accent (AdwSettings *self);
+
 G_END_DECLS
diff --git a/src/adw-settings.c b/src/adw-settings.c
index 12e908d..8ff44c2 100644
--- a/src/adw-settings.c
+++ b/src/adw-settings.c
@@ -35,6 +35,7 @@ struct _AdwSettings
 
   AdwSystemColorScheme color_scheme;
   gboolean high_contrast;
+  gchar *yaru_accent;
 
   gboolean has_high_contrast;
   gboolean has_color_scheme;
@@ -53,6 +54,7 @@ enum {
   PROP_SYSTEM_SUPPORTS_COLOR_SCHEMES,
   PROP_COLOR_SCHEME,
   PROP_HIGH_CONTRAST,
+  PROP_YARU_ACCENT,
   LAST_PROP,
 };
 
@@ -499,6 +501,177 @@ init_legacy (AdwSettings *self)
                             self);
 }
 
+static void
+update_yaru_accent_from_theme (AdwSettings *self,
+                               const char *theme_name)
+{
+  g_autofree char *old_accent = g_steal_pointer (&self->yaru_accent);
+
+  if (self->override)
+    return;
+
+  g_assert (self->yaru_accent == NULL);
+
+  if (g_str_has_prefix (theme_name, "Yaru")) {
+    if (g_str_equal (theme_name, "Yaru") ||
+        g_str_equal (theme_name, "Yaru-dark")) {
+      self->yaru_accent = g_strdup ("default");
+    } else {
+      g_auto (GStrv) theme_variant = NULL;
+
+      theme_variant = g_strsplit (theme_name, "-", -1);
+      g_assert (g_strv_length (theme_variant) > 1);
+
+      self->yaru_accent = g_strdup (theme_variant[1]);
+    }
+  }
+
+  if (g_strcmp0 (old_accent, self->yaru_accent) != 0)
+    g_object_notify_by_pspec (G_OBJECT (self), props[PROP_YARU_ACCENT]);
+}
+
+static gboolean
+update_yaru_accent_from_gsettings (AdwSettings *self)
+{
+  g_autofree char *theme_name = NULL;
+
+  if (!self->interface_settings)
+    return FALSE;
+
+  theme_name = g_settings_get_string (self->interface_settings, "gtk-theme");
+  update_yaru_accent_from_theme (self, theme_name);
+
+  return TRUE;
+}
+
+static gboolean
+update_yaru_accent_from_gtk (AdwSettings *self)
+{
+  GdkDisplay *display = gdk_display_get_default ();
+  g_auto(GValue) value = G_VALUE_INIT;
+
+  if (!display)
+    return FALSE;
+
+  g_value_init (&value, G_TYPE_STRING);
+  if (!gdk_display_get_setting (display, "gtk-theme-name", &value))
+    return FALSE;
+
+  update_yaru_accent_from_theme (self, g_value_get_string (&value));
+
+  return TRUE;
+}
+
+static gboolean
+update_yaru_accent_from_portal (AdwSettings *self)
+{
+  g_autoptr (GVariant) variant = NULL;
+
+  if (get_disable_portal () || !self->settings_portal)
+    return FALSE;
+
+  if (read_portal_setting (self, "org.gnome.desktop.interface",
+                           "gtk-theme", "s", &variant)) {
+    update_yaru_accent_from_theme (self, g_variant_get_string (variant, NULL));
+    return TRUE;
+  }
+
+  return FALSE;
+}
+
+static void
+on_yaru_display_setting_changed (AdwSettings *self,
+                                 const char  *setting,
+                                 GdkDisplay  *display)
+{
+  if (!g_strcmp0 (setting, "gtk-theme-name"))
+    update_yaru_accent_from_gtk (self);
+}
+
+static void
+on_yaru_settings_portal_changed (GDBusProxy  *proxy,
+                                 const char  *sender_name,
+                                 const char  *signal_name,
+                                 GVariant    *parameters,
+                                 AdwSettings *self)
+{
+  g_autoptr(GVariant) value = NULL;
+  const char *namespace;
+  const char *name;
+
+  if (g_strcmp0 (signal_name, "SettingChanged") != 0)
+    return;
+
+  g_variant_get (parameters, "(&s&sv)", &namespace, &name, &value);
+
+  if (g_strcmp0 (namespace, "org.gnome.desktop.interface") == 0 &&
+      g_strcmp0 (name, "gtk-theme") == 0) {
+    update_yaru_accent_from_theme (self, g_variant_get_string (value, NULL));
+  }
+}
+
+typedef enum {
+  ADW_YARU_ACCENT_SOURCE_NONE,
+  ADW_YARU_ACCENT_SOURCE_PORTAL,
+  ADW_YARU_ACCENT_SOURCE_GTK,
+  ADW_YARU_ACCENT_SOURCE_GSETTINGS,
+} AdwYaruAccentSource;
+
+static AdwYaruAccentSource
+update_yaru_accent (AdwSettings *self)
+{
+  if (update_yaru_accent_from_portal (self))
+    return ADW_YARU_ACCENT_SOURCE_PORTAL;
+
+  if (update_yaru_accent_from_gtk (self))
+    return ADW_YARU_ACCENT_SOURCE_GTK;
+
+  if (update_yaru_accent_from_gsettings (self))
+    return ADW_YARU_ACCENT_SOURCE_GSETTINGS;
+
+  return ADW_YARU_ACCENT_SOURCE_NONE;
+}
+
+static void
+init_yaru_accents (AdwSettings *self)
+{
+  AdwYaruAccentSource accent_source;
+
+  if (!self->interface_settings)
+    self->interface_settings = g_settings_new ("org.gnome.desktop.interface");
+
+  accent_source = update_yaru_accent (self);
+
+  switch (accent_source) {
+    case ADW_YARU_ACCENT_SOURCE_PORTAL:
+      g_signal_connect (self->settings_portal, "g-signal",
+                        G_CALLBACK (on_yaru_settings_portal_changed), self);
+      break;
+
+    case ADW_YARU_ACCENT_SOURCE_GTK:
+      g_signal_connect_object (gdk_display_get_default (),
+                               "setting-changed",
+                               G_CALLBACK (on_yaru_display_setting_changed),
+                               self, G_CONNECT_SWAPPED);
+      break;
+
+    case ADW_YARU_ACCENT_SOURCE_GSETTINGS:
+      g_signal_connect_object (self->interface_settings,
+                               "changed::gtk-theme",
+                               G_CALLBACK (update_yaru_accent_from_gsettings),
+                               self, G_CONNECT_SWAPPED);
+      break;
+
+    case ADW_YARU_ACCENT_SOURCE_NONE:
+    default:
+      g_warning ("No source found for Yaru accent color");
+      break;
+  }
+
+  if (accent_source != ADW_YARU_ACCENT_SOURCE_GSETTINGS)
+    g_clear_object (&self->interface_settings);
+}
+
 static void
 adw_settings_constructed (GObject *object)
 {
@@ -517,6 +690,8 @@ adw_settings_constructed (GObject *object)
 
   if (!self->has_high_contrast)
     init_legacy (self);
+
+  init_yaru_accents (self);
 }
 
 static void
@@ -527,6 +702,7 @@ adw_settings_dispose (GObject *object)
   g_clear_object (&self->settings_portal);
   g_clear_object (&self->interface_settings);
   g_clear_object (&self->a11y_settings);
+  g_clear_pointer (&self->yaru_accent, g_free);
 
   G_OBJECT_CLASS (adw_settings_parent_class)->dispose (object);
 }
@@ -552,6 +728,10 @@ adw_settings_get_property (GObject    *object,
     g_value_set_boolean (value, adw_settings_get_high_contrast (self));
     break;
 
+  case PROP_YARU_ACCENT:
+    g_value_set_string (value, adw_settings_get_yaru_accent (self));
+    break;
+
   default:
     G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
   }
@@ -588,6 +768,13 @@ adw_settings_class_init (AdwSettingsClass *klass)
                           FALSE,
                           G_PARAM_READABLE);
 
+  props[PROP_YARU_ACCENT] =
+    g_param_spec_string ("yaru-accent",
+                         "Yaru Accent",
+                         "Yaru Accent",
+                         NULL,
+                         G_PARAM_READABLE);
+
   g_object_class_install_properties (object_class, LAST_PROP, props);
 }
 
@@ -678,6 +865,8 @@ adw_settings_end_override (AdwSettings *self)
     g_object_notify_by_pspec (G_OBJECT (self), props[PROP_COLOR_SCHEME]);
   if (notify_hc)
     g_object_notify_by_pspec (G_OBJECT (self), props[PROP_HIGH_CONTRAST]);
+
+  update_yaru_accent (self);
 }
 
 void
@@ -732,3 +921,9 @@ adw_settings_override_high_contrast (AdwSettings *self,
 
   g_object_notify_by_pspec (G_OBJECT (self), props[PROP_HIGH_CONTRAST]);
 }
+
+const char *
+adw_settings_get_yaru_accent (AdwSettings *self)
+{
+  return self->yaru_accent;
+}
diff --git a/src/adw-style-manager.c b/src/adw-style-manager.c
index ae1a858..c83d84b 100644
--- a/src/adw-style-manager.c
+++ b/src/adw-style-manager.c
@@ -161,18 +161,48 @@ update_stylesheet (AdwStyleManager *self)
     if (adw_settings_get_high_contrast (self->settings))
       gtk_css_provider_load_from_resource (self->provider,
                                            "/org/gnome/Adwaita/styles/base-hc.css");
+    else if (adw_settings_get_yaru_accent (self->settings))
+      gtk_css_provider_load_from_resource (self->provider,
+                                           "/org/gnome/Adwaita/styles/base-yaru.css");
     else
       gtk_css_provider_load_from_resource (self->provider,
                                            "/org/gnome/Adwaita/styles/base.css");
   }
 
   if (self->colors_provider) {
+    g_autofree char *style = NULL;
+    g_autofree char *variant = NULL;
+
     if (self->dark)
-      gtk_css_provider_load_from_resource (self->colors_provider,
-                                           "/org/gnome/Adwaita/styles/defaults-dark.css");
+      variant = g_strdup ("defaults-dark");
     else
-      gtk_css_provider_load_from_resource (self->colors_provider,
-                                           "/org/gnome/Adwaita/styles/defaults-light.css");
+      variant = g_strdup ("defaults-light");
+
+    if (!adw_settings_get_high_contrast (self->settings)) {
+      const char *yaru_accent = adw_settings_get_yaru_accent (self->settings);
+
+      if (yaru_accent) {
+        g_autoptr (GFile) gresource = NULL;
+        g_autofree char *base_variant = g_steal_pointer (&variant);
+        g_autofree char *yaru_variant = NULL;
+        g_autofree char *resource_uri = NULL;
+
+        yaru_variant = g_strdup_printf ("%s-yaru-%s", base_variant, yaru_accent);
+        resource_uri = g_strdup_printf ("resource:///org/gnome/Adwaita/styles/%s.css", yaru_variant);
+        gresource = g_file_new_for_uri (resource_uri);
+
+        if (g_file_query_exists (gresource, NULL)) {
+          variant = g_steal_pointer (&yaru_variant);
+        } else {
+          variant = g_steal_pointer (&base_variant);
+          g_warning ("No known Yaru accent '%s'", yaru_accent);
+        }
+      }
+    }
+
+    style = g_strdup_printf ("/org/gnome/Adwaita/styles/%s.css", variant);
+    g_debug ("Using style %s", style);
+    gtk_css_provider_load_from_resource (self->colors_provider, style);
   }
 
   self->animation_timeout_id =
@@ -296,6 +326,11 @@ adw_style_manager_constructed (GObject *object)
                            G_CALLBACK (notify_high_contrast_cb),
                            self,
                            G_CONNECT_SWAPPED);
+  g_signal_connect_object (self->settings,
+                           "notify::yaru-accent",
+                           G_CALLBACK (update_stylesheet),
+                           self,
+                           G_CONNECT_SWAPPED);
 
   update_dark (self);
   update_stylesheet (self);
diff --git a/src/stylesheet/_defaults.scss b/src/stylesheet/_defaults.scss
index 1435566..6593f0e 100644
--- a/src/stylesheet/_defaults.scss
+++ b/src/stylesheet/_defaults.scss
@@ -8,10 +8,13 @@
 // These are the colors apps are can override. We define the defaults here and
 // define variables for them in _colors.scss
 
+$accent_bg_color: '@blue_3' !default;
+$accent_color: #{if($variant == 'dark', #78aeed, "@blue_4")} !default
+
 // The main accent color and the matching text value
-@define-color accent_bg_color @blue_3;
+@define-color accent_bg_color #{$accent_bg_color};
 @define-color accent_fg_color white;
-@define-color accent_color #{if($variant == 'dark', #78aeed, "@blue_4")};
+@define-color accent_color #{$accent_color};
 
 // destructive-action buttons
 @define-color destructive_bg_color #{if($variant == 'dark', "@red_4", "@red_3")};
diff --git a/src/stylesheet/_palette-yaru.scss b/src/stylesheet/_palette-yaru.scss
new file mode 100644
index 0000000..d537841
--- /dev/null
+++ b/src/stylesheet/_palette-yaru.scss
@@ -0,0 +1,97 @@
+// Keep this in sync with
+//   https://github.com/ubuntu/yaru/blob/master/gtk/src/default/gtk-4.0/_palette.scss
+
+$blue_1: #75d3f4;
+$blue_2: #47c4f1;
+$blue_3: #19b6ee; // Yaru blue
+$blue_4: #007aa6; // Yaru linkblue
+$blue_5: #335280; // Yaru darkblue
+$green_1: #5aed70;
+$green_2: #47d35c;
+$green_3: #34b948;
+$green_4: #219e34;
+$green_5: #0e8420; // Yaru green
+$yellow_1: #fccd87;
+$yellow_2: #fbc16a;
+$yellow_3: #fbb44c;
+$yellow_4: #faa82f;
+$yellow_5: #f99b11; // Yaru yellow
+$orange_1: #f29879;
+$orange_2: #f08763;
+$orange_3: #ed764d;
+$orange_4: #eb6536;
+$orange_5: #e95420; // Yaru orange
+$red_1: #ea485c;
+$red_2: #de374c;
+$red_3: #d3273b;
+$red_4: #c7162b; // Yaru red
+$red_5: #a91224;
+$purple_1: #924d8b; // Yaru aubergine
+$purple_2: #762572; // Yaru purple
+$purple_3: #77216f; // Yaru light aubergine
+$purple_4: #5e2750; // Yaru mid aubergine
+$purple_5: #2c001e; // Yaru dark aubergine
+$brown_1: #e1b289;
+$brown_2: #c5976e;
+$brown_3: #aa7b53;
+$brown_4: #8e6038;
+$brown_5: #72441d;
+$light_1: #ffffff;
+$light_2: #f7f7f7; // Yaru porcelain
+$light_3: #ccc; // Yaru silk
+$light_4: #aea79f; // Yaru warm gray
+$light_5: #878787; // Yaru ash
+$dark_1: #666666; // Yaru graphite
+$dark_2: #5d5d5d; // Yaru slate
+$dark_3: #3d3d3d; // Yaru inkstone
+$dark_4: #181818; // Yaru jet
+$dark_5: #000000;
+
+// Sass thinks we're using the colors in the variables as strings and may shoot
+// warning, it's innocuous and can be defeated by using #{$var}.
+
+@define-color blue_1 #{$blue_1};
+@define-color blue_2 #{$blue_2};
+@define-color blue_3 #{$blue_3};
+@define-color blue_4 #{$blue_4};
+@define-color blue_5 #{$blue_5};
+@define-color green_1 #{$green_1};
+@define-color green_2 #{$green_2};
+@define-color green_3 #{$green_3};
+@define-color green_4 #{$green_4};
+@define-color green_5 #{$green_5};
+@define-color yellow_1 #{$yellow_1};
+@define-color yellow_2 #{$yellow_2};
+@define-color yellow_3 #{$yellow_3};
+@define-color yellow_4 #{$yellow_4};
+@define-color yellow_5 #{$yellow_5};
+@define-color orange_1 #{$orange_1};
+@define-color orange_2 #{$orange_2};
+@define-color orange_3 #{$orange_3};
+@define-color orange_4 #{$orange_4};
+@define-color orange_5 #{$orange_5};
+@define-color red_1 #{$red_1};
+@define-color red_2 #{$red_2};
+@define-color red_3 #{$red_3};
+@define-color red_4 #{$red_4};
+@define-color red_5 #{$red_5};
+@define-color purple_1 #{$purple_1};
+@define-color purple_2 #{$purple_2};
+@define-color purple_3 #{$purple_3};
+@define-color purple_4 #{$purple_4};
+@define-color purple_5 #{$purple_5};
+@define-color brown_1 #{$brown_1};
+@define-color brown_2 #{$brown_2};
+@define-color brown_3 #{$brown_3};
+@define-color brown_4 #{$brown_4};
+@define-color brown_5 #{$brown_5};
+@define-color light_1 #{$light_1};
+@define-color light_2 #{$light_2};
+@define-color light_3 #{$light_3};
+@define-color light_4 #{$light_4};
+@define-color light_5 #{$light_5};
+@define-color dark_1 #{$dark_1};
+@define-color dark_2 #{$dark_2};
+@define-color dark_3 #{$dark_3};
+@define-color dark_4 #{$dark_4};
+@define-color dark_5 #{$dark_5};
diff --git a/src/stylesheet/adwaita-stylesheet.gresources.xml b/src/stylesheet/adwaita-stylesheet.gresources.xml
index 98a07ac..0d86a06 100644
--- a/src/stylesheet/adwaita-stylesheet.gresources.xml
+++ b/src/stylesheet/adwaita-stylesheet.gresources.xml
@@ -5,6 +5,7 @@
     <file>base-hc.css</file>
     <file>defaults-light.css</file>
     <file>defaults-dark.css</file>
+    @ACCENTS_CSS@
 
     <file>assets/bullet-symbolic.symbolic.png</file>
     <file>assets/bullet@2-symbolic.symbolic.png</file>
diff --git a/src/stylesheet/meson.build b/src/stylesheet/meson.build
index 2c0fa82..41d9e14 100644
--- a/src/stylesheet/meson.build
+++ b/src/stylesheet/meson.build
@@ -2,14 +2,60 @@ fs = import('fs')
 
 stylesheet_deps = []
 
+yaru_accent_colors_sassc = []
+
+if get_option('yaru-accent-colors')
+  YARU_ACCENTS = [
+      'default',
+      'bark',
+      'sage',
+      'olive',
+      'viridian',
+      'prussiangreen',
+      'blue',
+      'purple',
+      'magenta',
+      'red',
+  ]
+
+  yaru_accent_colors_sassc += configure_file(
+    command: [ 'sed', 's,palette,palette-yaru,g', '@INPUT@' ],
+    capture: true,
+    input: 'base.scss',
+    output: 'base-yaru.scss',
+  )
+
+  yaru_accent_colors = 'yaru_accent_colors.scss'
+  foreach accent: YARU_ACCENTS
+    foreach variant: ['light', 'dark']
+      yaru_accent_colors_sassc += configure_file(
+        configuration: {
+          'yaru_dark_variant': variant == 'dark' ? 'true' : 'false',
+          'yaru_accent_color': accent,
+          'yaru_theme_entry_point': (meson.project_source_root() /
+            '@0@'.format(files('defaults-@0@.scss'.format(variant))[0])),
+        },
+        input: yaru_accent_colors,
+        output: 'defaults-@0@-yaru-@1@.scss'.format(variant, accent),
+      )
+    endforeach
+  endforeach
+endif
+
+build_yaru_accent_colors = yaru_accent_colors_sassc.length() > 0
+
 # For git checkouts, but not for tarballs...
-if not fs.exists('base.css')
+if not fs.exists('base.css') or build_yaru_accent_colors
   sassc = find_program('sassc', required: false)
   if not sassc.found()
     subproject('sassc')
     sassc = find_program('sassc')
   endif
 
+  if build_yaru_accent_colors
+    assert(sassc.found(), 'No SSSC found, needed for accent colors!')
+  endif
+
   if sassc.found()
     sassc_opts = [ '-a', '-M', '-t', 'compact' ]
 
@@ -72,10 +118,21 @@ if not fs.exists('base.css')
       'defaults-dark',
     ]
 
+    if build_yaru_accent_colors
+      foreach accent_definition: yaru_accent_colors_sassc
+        scss_deps += accent_definition
+        scss_files += accent_definition
+      endforeach
+
+      scss_deps += yaru_accent_colors
+      sassc_opts += [ '-I', meson.project_build_root() ]
+      sassc_opts += [ '-I', meson.current_source_dir() ]
+    endif
+
     foreach scss: scss_files
-      stylesheet_deps += custom_target('@0@.scss'.format(scss),
-        input: '@0@.scss'.format(scss),
-        output: '@0@.css'.format(scss),
+      stylesheet_deps += custom_target('@0@.scss'.format(fs.name(scss)),
+        input: '@0@'.format(scss).endswith('.scss') ? scss : '@0@.scss'.format(scss),
+        output: '@0@.css'.format(fs.stem(scss)),
         command: [
           sassc, sassc_opts, '@INPUT@', '@OUTPUT@',
         ],
@@ -85,9 +142,24 @@ if not fs.exists('base.css')
   endif
 endif
 
+accents_css = []
+foreach accent_definition: yaru_accent_colors_sassc
+  accents_css += '<file alias="@0@">@1@/@2@</file>'.format(
+    fs.stem(accent_definition) + '.css', meson.project_build_root(),
+    fs.replace_suffix(accent_definition, '.css'))
+endforeach
+
+gresource_file = configure_file(
+  input: 'adwaita-stylesheet.gresources.xml',
+  output: '@BASENAME@',
+  configuration: {
+    'ACCENTS_CSS': accents_css.length() > 0 ? '\n'.join(accents_css) : '',
+  }
+)
+
 libadwaita_stylesheet_resources = gnome.compile_resources(
   'adwaita-stylesheet-resources',
-  'adwaita-stylesheet.gresources.xml',
+  gresource_file,
 
   source_dir: [
     # List in order of preference
diff --git a/src/stylesheet/yaru_accent_colors.scss b/src/stylesheet/yaru_accent_colors.scss
new file mode 100644
index 0000000..d826acf
--- /dev/null
+++ b/src/stylesheet/yaru_accent_colors.scss
@@ -0,0 +1,39 @@
+// Keep this in sync with
+//   https://github.com/ubuntu/yaru/blob/master/common/accent-colors.scss.in
+
+@function get_accent_color($accent_color, $is_dark: false) {
+    $color: null;
+    @if $accent_color == 'default' {
+        $color: #E95420;
+    } @else if $accent_color == 'bark' {
+        $color: #787859;
+    } @else if $accent_color == 'sage' {
+        $color: #657B69;
+    } @else if $accent_color == 'olive' {
+        $color: #4B8501;
+    } @else if $accent_color == 'viridian' {
+        $color: #03875B;
+    } @else if $accent_color == 'prussiangreen' {
+        $color: #308280;
+    } @else if $accent_color == 'blue' {
+        $color: #0073E5;
+    } @else if $accent_color == 'purple' {
+        $color: #7764D8;
+    } @else if $accent_color == 'magenta' {
+        $color: #B34CB3;
+    } @else if $accent_color == 'red' {
+        $color: #DA3450;
+    } @else {
+        @error('No known accent color defined!');
+    }
+    @debug('Using accent color ' + $accent_color + ': ' + $color);
+    @return $color;
+}
+
+$yaru_is_dark_variant: @yaru_dark_variant@;
+$yaru_accent_bg_color: get_accent_color('@yaru_accent_color@', $yaru_is_dark_variant);
+$accent_bg_color: $yaru_accent_bg_color;
+$accent_color: $yaru_accent_bg_color;
+@debug("Accent color is " + $yaru_accent_bg_color);
+
+@import '@yaru_theme_entry_point@'
