Want to change system color scheme and accent color from command line? Here’s how to do the trick in Ubuntu 22.04 LTS.
You know, Ubuntu 22.04 introduced an option to one click switching between light and dark mode for system wide. As well, there are 10 accent colors available to apply for highlight text, toggle button, input box, folder icon, etc.
For app developers or those who want to write a script with ability to toggle system color scheme, here are the keys you need!
system wide color scheme
Like other hidden options, single gsettings
command may toggle system light and dark mode. And, the key is “color-scheme” under “org.gnome.desktop.interface”.
To get the current value, use command:
gsettings get org.gnome.desktop.interface color-scheme
The output can be: ‘default
‘, ‘prefer-light
‘, or ‘prefer-dark
‘.
And, to change system color scheme, for example to dark, use command :
gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
You may reset the color scheme to ‘default’ (though color won’t change) by running command:
gsettings reset org.gnome.desktop.interface color-scheme
So, you may run previous command directly in bash script, or get the current value via:
ClrScheme=$(gsettings get org.gnome.shell.ubuntu color-scheme)
Tip: The type of output value seems to be "Enumeration" rather than a 'String'.
Change Accent Color:
The accent colors are just the default Yaru GTK theme in 10 different colors. So changing accent color needs to change the GTK theme.
To get current GTK theme, use command:
gsettings get org.gnome.desktop.interface gtk-theme
And, change its color (for example to blue) use command:
gsettings set org.gnome.desktop.interface gtk-theme 'Yaru-blue'
Depends on current color scheme (dark or light), it’s better to set the value to ‘Yaru-blue’ for light or ‘Yaru-blue-dark’ for dark mode.
The 9 colors besides the default (for each, add '-dark
' for dark mode) are "Yaru-bark", "Yaru-blue", "Yaru-magenta", "Yaru-olive", "Yaru-prussiangreen", "Yaru-purple", "Yaru-red", "Yaru-sage", "Yaru-viridian"
As well, change the icon theme as well via command (no dark for icons):
gsettings set org.gnome.desktop.interface icon-theme 'Yaru-blue'
Change System Menu color separately:
NOTE: The first commands under “system wide color scheme” will do the change automatically! This is only for those want to switch shell color separately.
For color of system menu, clock menu, notification, context menu, etc, there’s also a separately key to configure it.
To get the current shell color, use command:
gsettings get org.gnome.shell.ubuntu color-scheme
And change the shell color scheme (‘prefer-dark’ or ‘prefer-light’) via command:
gsettings set org.gnome.shell.ubuntu color-scheme 'prefer-dark'
NOTE: After using this command, "Appearance" color mode and the system-wide 'color-scheme' key will NO longer change the menu colors, until you reset it via the command below.
To reset the key use command:
gsettings reset org.gnome.shell.ubuntu color-scheme
That’s all. Enjoy!
Recent Comments