0

How do I script changing from the light mode to the dark mode? In it GUI I do this: preferences>profiles>Unnamed>Colors>Bultin-in schemes (here I choose either black-on-white or white-on-black.

As far as I know, there is no config file. I use Ubuntu 22.04LTS Desktop and have no /org in my filesystem. How might I automate the process of changing the color scheme scripting the whole process with dconf or similar tools? The goal is to run the script via cron that changes from black-on-white to white-on-black at 2pm and vice versa at 7am.

I already know how to launch gnome-terminal with desired settings saved in a profile, e.g. gnome-terminal --profile=dark. This is not what I want to achieve because I want the already opened windows to change the color scheme.

John Smith
  • 149
  • 1
  • 7
  • 1
    Did you look under `/org/gnome/terminal/legacy/profiles:/` in `dconf`? – FedKad Feb 27 '23 at 09:09
  • @FedKad I've added more information to my question in response to your comment. – John Smith Feb 27 '23 at 09:16
  • 1
    I am not talking about any `/org` directory. I am talking about the dconf key path. Please, try `dconf dump /org/gnome/terminal/legacy/profiles:/` – FedKad Feb 27 '23 at 09:18

1 Answers1

1

Please, use the command

dconf dump /org/gnome/terminal/legacy/profiles:/

and find the relevant "profile id" that has visible-name='Unnamed'.

Using the command dconf write key_path new_value, you can change the values of the following keys:

/org/gnome/terminal/legacy/profiles:/<profile_id>/background-color
/org/gnome/terminal/legacy/profiles:/<profile_id>/foreground-color

e.g. changing to dark theme:

dconf write /org/gnome/terminal/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9/background-color "'#000000'"
dconf write /org/gnome/terminal/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9/foreground-color "'#ffffff'"

where :b1dcc9dd-5262-4d8d-a863-c897e6d979b9 is your profile id.

John Smith
  • 149
  • 1
  • 7
FedKad
  • 9,212
  • 7
  • 40
  • 79
  • `dconf dump /org/gnome/terminal/legacy/profiles:/` gave me this `[:b1dcc9dd-5262-4d8d-a863-c897e6d979b9] background-color='rgb(255,255,255)' font='Monospace 21' foreground-color='rgb(0,0,0)' use-system-font=false use-theme-colors=false` This **Unnamed** profile is not a profile that I created, it is on every Ubuntu Desktop installation. `b1dcc9dd-5262-4d8d-a863-c897e6d979b9` seems to be its id. I figured out how to do this manually from `dconf-editor` but I need a solution that is non-interactive and can be run as a script via cron. – John Smith Feb 27 '23 at 10:00
  • 1
    Use the `dconf write key_path new_value` command in a script. Please, note that these values are _per user_, so your cron script should be run from the current user. – FedKad Feb 27 '23 at 10:12