# Automatic Dark Mode

**URL:** https://meta.discourse.org/t/automatic-dark-mode/278606
**Category:** Support
**Tags:** auto-dark
**Created:** [September 11, 2023, 8:36pm UTC](https://meta.discourse.org/t/automatic-dark-mode/278606 "2023-09-11T20:36:45Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![kynic](https://avatars.discourse-cdn.com/v4/letter/k/b487fb/32.png) [@kynic](https://meta.discourse.org/u/kynic)
#### Post date: [September 11, 2023, 8:36pm UTC](https://meta.discourse.org/t/automatic-dark-mode/278606/1 "2023-09-11T20:36:45Z")

</div>

How should I enable the “automatic dark mode color scheme” for all users overriding their account settings?

---

<div class="post-metadata">

### Author: ![inj3ct0r](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/inj3ct0r/32/324428_2.png) [@inj3ct0r](https://meta.discourse.org/u/inj3ct0r)
#### Post date: [September 11, 2023, 9:40pm UTC](https://meta.discourse.org/t/automatic-dark-mode/278606/2 "2023-09-11T21:40:12Z")

</div>

I guess u need to force the users by disable the ability to choice the color scheme  
go to settings → customization → colors → The color scheme can be selected by users ((disable it))

then go back to the style and sign a color scheme thats will appear to the users by force

---

<div class="post-metadata">

### Author: ![kynic](https://avatars.discourse-cdn.com/v4/letter/k/b487fb/32.png) [@kynic](https://meta.discourse.org/u/kynic)
#### Post date: [September 11, 2023, 9:45pm UTC](https://meta.discourse.org/t/automatic-dark-mode/278606/3 "2023-09-11T21:45:32Z")

</div>

Thanks for trying to help 🙂

It is already disabled.

I am asking for this As mentioned here: [Automatic Dark Mode color scheme switching](https://meta.discourse.org/t/automatic-dark-mode-color-scheme-switching/161593)

[![](https://global.discourse-cdn.com/meta/optimized/3X/5/6/56aa63cdae8dd9b988a69a98d273114002eef4ab_2_345x72.png) ](https://global.discourse-cdn.com/meta/optimized/3X/5/6/56aa63cdae8dd9b988a69a98d273114002eef4ab_2_345x72.png)

I want this setting to force enable for all users but I can’t seem to find a way for it.

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [September 11, 2023, 10:18pm UTC](https://meta.discourse.org/t/automatic-dark-mode/278606/4 "2023-09-11T22:18:15Z")

</div>

Perhaps you want the `default dark mode color scheme id` in admin-settings?

 ![IMG_0393](https://global.discourse-cdn.com/meta/original/4X/c/e/7/ce7655ec3e5772b019d090d67e1cc630f47a400b.jpeg)

* * *
Discourse settings bot says:

> [@Lola the Discourse settings bot](#):
>
> > **Look up site setting context**
> >
> > Reading context for: default\_dark\_mode\_color\_scheme\_id
> 
> The `default_dark_mode_color_scheme_id` is a Discourse site setting that determines the color scheme used when the site is in dark mode.
> 
> Here’s a brief overview of how it works:
> 
> - It’s an enum type setting, meaning it can take one value from a defined list of options. These options are defined in the `ColorSchemeSetting`.
> - Its default value is -1, which means there is no specific dark mode color scheme set by default.
> - It’s a client-side setting, meaning it affects how the site is displayed to the user.
> - This setting is used in various places in the Discourse codebase, such as in the stylesheet manager, the wizard builder, and the user preferences interface.
> - For example, in the stylesheet manager, it’s used to determine which color schemes to precompile for dark mode.
> - In the user preferences interface, it’s used to provide the default dark mode color scheme to the user.
> - If a dark color scheme is set but the user doesn’t auto switch in dark mode, the stylesheet is loaded manually.
> 
> Please note that if you change this setting, it will affect the appearance of your site for users who have chosen to use dark mode.

---

<div class="post-metadata">

### Author: ![kynic](https://avatars.discourse-cdn.com/v4/letter/k/b487fb/32.png) [@kynic](https://meta.discourse.org/u/kynic)
#### Post date: [September 11, 2023, 10:29pm UTC](https://meta.discourse.org/t/automatic-dark-mode/278606/5 "2023-09-11T22:29:48Z")

</div>

It’s set to dark color scheme

A few users reported that this setting is not enabled for them and they having issues seeing the logo in dark mode after enabling the setting it fixes the issue.

I was wondering why this setting is not enabled for all users. That’s why I was looking for a way to force enable for all users.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [September 12, 2023, 8:42am UTC](https://meta.discourse.org/t/automatic-dark-mode/278606/6 "2023-09-12T08:42:55Z")

</div>

> [@kynic](#):
>
> I was wondering why this setting is not enabled for all users. That’s why I was looking for a way to force enable for all users.

You can’t do that from the interface.  
You can bulk update user options using a rails command, though it’s to be done with caution.  
I suggest you first check how many users have this setting disabled using [data explorer](https://meta.discourse.org/t/32566?silent=true), for example. If the number isn’t high, you can set it manually or ask users to do it themselves.

I think you should also ensure what is the default value when an account is created.

---

<div class="post-metadata">

### Author: ![kynic](https://avatars.discourse-cdn.com/v4/letter/k/b487fb/32.png) [@kynic](https://meta.discourse.org/u/kynic)
#### Post date: [September 13, 2023, 2:03am UTC](https://meta.discourse.org/t/automatic-dark-mode/278606/7 "2023-09-13T02:03:20Z")

</div>

Thank you can you please tell me the rails commands?

I have [data explorer](https://meta.discourse.org/t/32566?silent=true) installed can you tell me script to see how many users have it enabled?

Thank you for your help really appreciate it. ❤

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [September 13, 2023, 9:07am UTC](https://meta.discourse.org/t/automatic-dark-mode/278606/8 "2023-09-13T09:07:16Z")

</div>

By default, the Dark Mode user setting is “Same as regular”.

In the database, it’s defined by `user_options.dark_scheme` value being `NULL`.  
“Dark” is `-1`. Other values are positive integers.

The query to return users that don’t have the default value would be:

```sql
SELECT 
    u.username,
    up.dark_scheme_id
FROM 
    users AS u
JOIN 
    user_options AS up
ON 
    u.id = up.user_id
WHERE up.dark_scheme_id IS NOT NULL

```

---

<div class="post-metadata">

### Author: ![kynic](https://avatars.discourse-cdn.com/v4/letter/k/b487fb/32.png) [@kynic](https://meta.discourse.org/u/kynic)
#### Post date: [September 13, 2023, 2:22pm UTC](https://meta.discourse.org/t/automatic-dark-mode/278606/9 "2023-09-13T14:22:08Z")

</div>

There are 59 results.

Now how I can bulk change their settings with rails commands?

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [September 13, 2023, 2:39pm UTC](https://meta.discourse.org/t/automatic-dark-mode/278606/10 "2023-09-13T14:39:20Z")

</div>

I’m a bit confused now. Why would you like to break user’s choise of colors? If you wouldn’ want to give choises then uninstall every other color schemes than default light and dark. That’s it.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [September 13, 2023, 2:46pm UTC](https://meta.discourse.org/t/automatic-dark-mode/278606/11 "2023-09-13T14:46:56Z")

</div>

You can reset this preference for the users that changed it with this rails script:

```rb
UserOption.where.not(dark_scheme_id: nil).find_each do |uo|
    uo.update(dark_scheme_id: nil)
end

```

I successfully used it on my test instance, but keep in mind I’m not a rails expert and, of course, always do a backup first. 🙂

---

<div class="post-metadata">

### Author: ![kynic](https://avatars.discourse-cdn.com/v4/letter/k/b487fb/32.png) [@kynic](https://meta.discourse.org/u/kynic)
#### Post date: [September 13, 2023, 2:47pm UTC](https://meta.discourse.org/t/automatic-dark-mode/278606/12 "2023-09-13T14:47:05Z")

</div>

There are no choices. Just this setting is not enabled by default for many after I selected a dark color scheme for the automatic dark mode from the site settings.

I want this to be enabled for all. But there are 59 users that don’t have this enabled by default don’t know why.

[![](https://global.discourse-cdn.com/meta/optimized/3X/5/6/56aa63cdae8dd9b988a69a98d273114002eef4ab_2_345x72.png) ](https://global.discourse-cdn.com/meta/optimized/3X/5/6/56aa63cdae8dd9b988a69a98d273114002eef4ab_2_345x72.png)

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [September 13, 2023, 2:47pm UTC](https://meta.discourse.org/t/automatic-dark-mode/278606/13 "2023-09-13T14:47:38Z")

</div>

Just to be clear, the setting in your screenshot is from the admin panel (server-wide), not a personal preference.

The latter being:

![image](https://global.discourse-cdn.com/meta/original/4X/4/8/6/48615b14a8e4203a656b62179146a4f3eb3438a0.png)

---

<div class="post-metadata">

### Author: ![kynic](https://avatars.discourse-cdn.com/v4/letter/k/b487fb/32.png) [@kynic](https://meta.discourse.org/u/kynic)
#### Post date: [September 13, 2023, 2:50pm UTC](https://meta.discourse.org/t/automatic-dark-mode/278606/14 "2023-09-13T14:50:11Z")

</div>

No, this is from user preference it shows for the users when you enable automatic dark mode from the site settings.

---

<div class="post-metadata">

### Author: ![kynic](https://avatars.discourse-cdn.com/v4/letter/k/b487fb/32.png) [@kynic](https://meta.discourse.org/u/kynic)
#### Post date: [September 13, 2023, 2:53pm UTC](https://meta.discourse.org/t/automatic-dark-mode/278606/15 "2023-09-13T14:53:03Z")

</div>

So I have to do this to be clear:

`cd /var/discourse`

`./launcher enter app`

Then

```plaintext
UserOption.where.not(dark_scheme_id: nil).find_each do |uo|
    uo.update(dark_scheme_id: nil)
end

```

Right?

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [September 13, 2023, 2:54pm UTC](https://meta.discourse.org/t/automatic-dark-mode/278606/16 "2023-09-13T14:54:33Z")

</div>

No, wait. I’m not sure I fully understand the request and I may lack some information about this dark mode setting 🤔

The site admin I found is:

 ![image](https://global.discourse-cdn.com/meta/original/4X/c/c/e/ccefcab38d1e1e7996bbc1d2b3f72df66cc04f75.png)

Where is the setting you’re talking about:

> [@kynic](#):
>
> when you enable automatic dark mode from the site settings.

?

---

<div class="post-metadata">

### Author: ![kynic](https://avatars.discourse-cdn.com/v4/letter/k/b487fb/32.png) [@kynic](https://meta.discourse.org/u/kynic)
#### Post date: [September 13, 2023, 2:56pm UTC](https://meta.discourse.org/t/automatic-dark-mode/278606/17 "2023-09-13T14:56:37Z")

</div>

Please see this:

> [@Automatic Dark Mode color scheme switching](https://meta.discourse.org/t/automatic-dark-mode-color-scheme-switching/161593):
>
> You can now set up your Discourse site to automatically switch color schemes when the user’s device is in dark mode. For a quick preview, head over to the [try.discourse.org](http://try.discourse.org) instance and toggle your device’s dark mode on and off to see this new feature in action. (This feature not enabled on meta.) Enabling automatic dark mode To enable this feature on your instance, you can pick the dark mode color scheme in your site settings: Once that setting is set, you can reload your site with …

It’s all about this one.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [September 13, 2023, 3:00pm UTC](https://meta.discourse.org/t/automatic-dark-mode/278606/18 "2023-09-13T15:00:14Z")

</div>

Okay. I had to disable color schemes to have this option showing up. I’ll get another read to this topic so I understand better.

---

<div class="post-metadata">

### Author: ![kynic](https://avatars.discourse-cdn.com/v4/letter/k/b487fb/32.png) [@kynic](https://meta.discourse.org/u/kynic)
#### Post date: [September 13, 2023, 3:04pm UTC](https://meta.discourse.org/t/automatic-dark-mode/278606/19 "2023-09-13T15:04:22Z")

</div>

> [@Canapin](#):
>
> ![image](https://global.discourse-cdn.com/meta/original/4X/c/c/e/ccefcab38d1e1e7996bbc1d2b3f72df66cc04f75.png)
> 
> image1089×204 7.16 KB

Yes! its " default dark mode color scheme id"

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [September 13, 2023, 3:07pm UTC](https://meta.discourse.org/t/automatic-dark-mode/278606/20 "2023-09-13T15:07:17Z")

</div>

Okay, so **unchecking** “Enable automatic dark mode color scheme” sets `user_options.dark_scheme` to `-1`, and **checking** sets it to **NULL**.

So, if you want all users to have this setting **checked** , you can use my script.

The default setting when a new use is created is **checked** as well.

> [@kynic](#):
>
> `./launcher enter app`

Do `rails c` after to enter the rails console.

If the script outputs a log, you can press q to exit it.

[Next page](https://meta.discourse.org/t/automatic-dark-mode/278606.md?page=2)
