Manage light/dark in Gnome script

This commit is contained in:
Anthony Rose 2024-06-05 12:53:14 +01:00
parent 3e3ca258c8
commit c5ea966b9d

View file

@ -1,5 +1,8 @@
#!/bin/sh
# Leave commented for light mode, or uncomment for dark mode.
_acp_dark_mode=1
test -x /usr/bin/gsettings || (echo "gsettings not found" && exit 1)
set_favorites_bar () {
@ -57,20 +60,32 @@ set_nautilus_preferences
set_gnome_terminal_preferences () {
gsettings set org.gnome.Terminal.Legacy.Settings menu-accelerator-enabled false
gsettings set org.gnome.Terminal.Legacy.Settings shortcuts-enabled false
gsettings set org.gnome.Terminal.Legacy.Settings theme-variant 'dark'
if [ -n $_acp_dark_mode ]
then
gsettings set org.gnome.Terminal.Legacy.Settings theme-variant 'dark'
else
gsettings set org.gnome.Terminal.Legacy.Settings theme-variant 'light'
fi
defaultprofile="org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:$(gsettings get org.gnome.Terminal.ProfilesList default | tr -d \')/"
gsettings set "$defaultprofile" audible-bell false
gsettings set "$defaultprofile" background-color '#101010'
gsettings set "$defaultprofile" default-size-columns 132
gsettings set "$defaultprofile" default-size-rows 24
gsettings set "$defaultprofile" foreground-color '#C0C0C0'
gsettings set "$defaultprofile" palette "[
_acp_terminal_profile="org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:$(gsettings get org.gnome.Terminal.ProfilesList default | tr -d \')/"
gsettings set "$_acp_terminal_profile" audible-bell false
gsettings set "$_acp_terminal_profile" default-size-columns 132
gsettings set "$_acp_terminal_profile" default-size-rows 24
gsettings set "$_acp_terminal_profile" palette "[
'#2E3436', '#CC0000', '#4E9A06', '#C4A000', '#3465A4', '#75507B', '#06989A', '#D3D7CF',
'#555753', '#EF2929', '#8AE234', '#FCE94F', '#729FCF', '#AD7FA8', '#34E2E2', '#EEEEEC'
]"
gsettings set "$defaultprofile" preserve-working-directory 'always'
gsettings set "$defaultprofile" use-theme-colors false
gsettings set "$_acp_terminal_profile" preserve-working-directory 'always'
gsettings set "$_acp_terminal_profile" use-theme-colors false
if [ -n $_acp_dark_mode ]
then
gsettings set "$_acp_terminal_profile" background-color '#101010'
gsettings set "$_acp_terminal_profile" foreground-color '#C0C0C0'
else
gsettings set "$_acp_terminal_profile" background-color '#EEEEEC'
gsettings set "$_acp_terminal_profile" foreground-color '#2E3436'
fi
unset _acp_terminal_profile
}
set_gnome_terminal_preferences
@ -146,12 +161,23 @@ set_misc_preferences () {
gsettings set org.gnome.desktop.background picture-options 'zoom'
gsettings set org.gnome.desktop.background picture-uri "file://$XDG_DATA_HOME/wallpaper-light.svg"
gsettings set org.gnome.desktop.background picture-uri-dark "file://$XDG_DATA_HOME/wallpaper-dark.svg"
gsettings set org.gnome.desktop.background primary-color '#101010'
gsettings set org.gnome.desktop.background secondary-color '#101010'
if [ -n $_acp_dark_mode ]
then
gsettings set org.gnome.desktop.background primary-color '#101010'
gsettings set org.gnome.desktop.background secondary-color '#101010'
else
gsettings set org.gnome.desktop.background primary-color '#008080'
gsettings set org.gnome.desktop.background secondary-color '#008080'
fi
# Prefer the dark theme.
gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita-dark'
if [ -n $_acp_dark_mode ]
then
gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita-dark'
else
gsettings set org.gnome.desktop.interface color-scheme 'prefer-light'
gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita'
fi
# Put the screen to sleep early without a password (to avoid image
# retention on this crappy laptop screen).
@ -168,3 +194,8 @@ if [ -r "${XDG_CONFIG_HOME:-$HOME/.config}/reset-gnome-setup.local" ]
then
. "${XDG_CONFIG_HOME:-$HOME/.config}/reset-gnome-setup.local"
fi
if [ -n $_acp_dark_mode ]
then
unset _acp_dark_mode
fi