Score:0

How do I script changing the color scheme in gnome-terminal?

in flag

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.

FedKad avatar
cn flag
Did you look under `/org/gnome/terminal/legacy/profiles:/` in `dconf`?
John Smith avatar
in flag
@FedKad I've added more information to my question in response to your comment.
FedKad avatar
cn flag
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:/`
Score:1
cn flag

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 avatar
in flag
`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.
FedKad avatar
cn flag
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.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.