3

I'd like to change the background color of the Ubuntu terminal emulator to say, red. However, I want to do it using the commandline, like the Windows equivalent color 0F, since I'm making a program that has changing the background color as a core function and I don't really want it to rely on any dependencies, unless it is really necessary.

Regarding the comment saying there's already an answer to this:

The answer on the question requires a package in order for it to work. I need a way for it to work without a package.

tequila
  • 41
  • 1
  • 5
  • With “Ubuntu terminal” you mean plain Ubuntu’s default terminal emulator `gnome-terminal`, don’t you? – dessert May 09 '19 at 11:40
  • Yes, I do. And also, it is not a duplicate of "Command-line to switch between profiles in gnome-terminal". The answer there requires a package to be installed. And I want a full background, not just behind the text. – tequila May 09 '19 at 11:47
  • What about [Changing colour of text and background of terminal?](https://askubuntu.com/q/558280/507051) – dessert May 09 '19 at 11:59
  • That doesn't change the color of the entire terminal. – tequila May 09 '19 at 12:01
  • Please add new information directly to your question ([edit]), *do not* use comments. ;) – dessert May 09 '19 at 12:07
  • And: Yes it does, see [this answer](https://askubuntu.com/a/558308/507051) on changing your profile color settings – does that help, e.g. `gconftool-2 --set "/apps/gnome-terminal/profiles//background_color" --type string "#000000"`? – dessert May 09 '19 at 12:09
  • ` Command 'gconftool-2' not found, but can be installed with: sudo apt install gconf2 ` – tequila May 09 '19 at 12:11
  • And you can’t even install *that*? I doubt there’s a way to alter your profile settings without `gconf`. – dessert May 09 '19 at 12:21
  • I can install that. However, I'm making a program that executes a command that changes the color, and I don't want it to rely on any dependencies. – tequila May 09 '19 at 12:23
  • Please add all that information to your question, comments are not supposed to hold important information like that. – dessert May 09 '19 at 12:24
  • Is your program for customizing the terminal, or making a text user interface (TUI), or something else? – wjandrea May 09 '19 at 13:10
  • TUI, the background color part is kinda important – tequila May 09 '19 at 13:21
  • 1
    @dessert gconftool-2 is not only no longer used by gnome-terminal, but also modifies the settings of _all_ the tabs running the given profile; unlikely what OP is looking for. tequila, you're perhaps looking for the OSC 10 / 11 escape sequences, see my new answer in one of the aforementioned duplicates. – egmont May 09 '19 at 13:56
  • @egmont OP wants to “change the background color of the Ubuntu terminal emulator”, I wouldn’t say that means just the current tab. If that other answer is just outdated please inform its OP about that so he can update it – this question is still a dupe in this case. – dessert May 09 '19 at 14:59
  • 1
    @dessert We definitely need clarification from OP (in case the duplicates don't answer their question). "I'm making a program that has changing the background color as a core function" - this suggests to me that it's that particular program that would set it only for the terminal where it's running. But it's indeed not fully clear. – egmont May 09 '19 at 15:35
  • This should be useful: [How do I create a terminal-based GUI? - Unix & Linux](https://unix.stackexchange.com/q/285777/117037) – wjandrea May 09 '19 at 18:48

1 Answers1

1

below script is to change only the Default Profile terminal background color.

script:

#!/bin/bash

defaultprofile=$(gsettings get org.gnome.Terminal.ProfilesList default)
profileID=$(echo "$defaultprofile" | cut -d "'" -f 2)
gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:$profileID/ background-color yellow

enter image description here

dessert
  • 39,392
  • 12
  • 115
  • 163
PRATAP
  • 21,989
  • 8
  • 59
  • 121