How to change the background color of gnome-terminal? - gnome-terminal

How to change the background color? I selected Profile > Background > solid color, but where can I select the color?

There are two well-supported ways to change the background color of an xterm (remember xterm != Terminal).
A. Set the color when you create the xterm:
E.g.,
% xterm -bg yellow &
OR
B. Edit .Xdefaults to include a color specification, such as the following:
XTerm*background:yellow
% vi ~/.Xdefaults (pick your favorite editor)
This can also be done by typing the following into an xterm:
% cat >> ~/.Xdefaults <RETURN>
XTerm*background:yellow<RETURN>
<CTRL-D>
Whichever way you change .Xdefaults, the change will not take effect until either:
xrdb ~/.Xdefaults
your X server is restarted, probably the easiest way to do that is reboot your machine, or log out.
Then it will be set once and for all.

I would suggest reversing the default foreground and background colors using
xterm -rv

I use the following colors and font setup for xterm.
Add the following to your ".Xresources" file in your home directory.
XTerm*faceName: Bitstream Vera Serif Mono
xterm*faceSize: 11
xterm*vt100*geometry: 80x60
xterm*saveLines: 16384
xterm*loginShell: true
xterm*charClass: 33:48,35:48,37:48,43:48,45-47:48,64:48,95:48,126:48
xterm*termName: xterm-color
xterm*eightBitInput: false
!BLK Cursor
#define _color0 #000d18
#define _color8 #000d18
!RED Tag
#define _color1 #e89393
#define _color9 #e89393
!GRN SpecialKey
#define _color2 #9ece13
#define _color10 #9ece13
!YEL Keyword
#define _color3 #f0dfaf
#define _color11 #f0dfaf
!BLU Number
#define _color4 #8cd0d3
#define _color12 #8cd0d3
!MAG Precondit
#define _color5 #c0bed1
#define _color13 #c0bed1
!CYN Float
#define _color6 #dfaf8f
#define _color14 #dfaf8f
!WHT Search
#define _color7 #efefef
#define _color15 #efefef
!FMT Include, StatusLine, ErrorMsg
#define _colorBD #ffcfaf
#define _colorUL #ccdc90
#define _colorIT #80d4aa
!TXT Normal, Normal, Cursor
#define _foreground #dcdccc
#define _background #1f1f1f
#define _cursorColor #8faf9f
URxvt*color0 : _color0
URxvt*color1 : _color1
URxvt*color2 : _color2
URxvt*color3 : _color3
URxvt*color4 : _color4
URxvt*color5 : _color5
URxvt*color6 : _color6
URxvt*color7 : _color7
URxvt*color8 : _color8
URxvt*color9 : _color9
URxvt*color10 : _color10
URxvt*color11 : _color11
URxvt*color12 : _color12
URxvt*color13 : _color13
URxvt*color14 : _color14
URxvt*color15 : _color15
URxvt*colorBD : _colorBD
URxvt*colorIT : _colorIT
URxvt*colorUL : _colorUL
URxvt*foreground : _foreground
URxvt*background : _background
URxvt*cursorColor : _cursorColor
XTerm*color0 : _color0
XTerm*color1 : _color1
XTerm*color2 : _color2
XTerm*color3 : _color3
XTerm*color4 : _color4
XTerm*color5 : _color5
XTerm*color6 : _color6
XTerm*color7 : _color7
XTerm*color8 : _color8
XTerm*color9 : _color9
XTerm*color10 : _color10
XTerm*color11 : _color11
XTerm*color12 : _color12
XTerm*color13 : _color13
XTerm*color14 : _color14
XTerm*color15 : _color15
XTerm*colorBD : _colorBD
XTerm*colorIT : _colorIT
XTerm*colorUL : _colorUL
XTerm*foreground : _foreground
XTerm*background : _background
XTerm*cursorColor : _cursorColor
When you have saved the file, run the following to save the changes:
xrdb -merge ~/.Xresources

Since it seems to be Terminal you're talking about, did you disable "Use colors from system theme" under Colors? Once you do that, you can pick a background color, still under the Colors tab. The Background tab looks like it only allows selecting an image (or transparency), which tripped me up as well.

Related

X11: Improving toggling of cursor dynamically at runtime

Context
I am toggling the presence of the mouse cursor depending on whether or not a mouse is plugged into my Linux system. I have created a solution that works, although sub optimally. My current solution is the following:
Modified WM: I extended a program supplied with my WM, matchbox-remote.c (see original source here), to allow a remote command that changes the cursor in real time. My change is based on this SO answer to a similar question.
Rules for udev: I added two udev rules that call matchbox-remote when a mouse is plugged in or unplugged, with my toggle argument.
Systemd service: I added a oneshot systemd service enables or disables the cursor on boot (depending on whether a mouse is plugged in or not). This addresses an edge-case where X is not yet ready when the udev rules first run.
If you would like to see how I have accomplished each step, move to the bottom where I have numbered sections with the relevant files
Problem
My solution works, but is suboptimal for two reasons:
The mouse cursor is present onscreen for a few seconds after the desktop loads if no mouse is plugged in, because the systemd rule runs after multi-user.target.
The mouse cursor remains present onscreen sometimes after being disabled. It disappears as soon as I interact with a button or other UI element. However, this can be quite annoying.
Attempted fixes
I have tried to do the following to improve my solution:
Reduce latency on boot: I tried to adjust my service file to start earlier in the boot progress. I specifically targeted it to start after xserver-nodm.service. However, this still fails to find the DISPLAY despite me manually setting it as an environment variable.
Disappear mouse pointer on event: I attempted to restart the WM, hoping that this would more seamlessly make the cursor disappear when it was supposed to. Unfortunately, this is a regressive solution as it makes the screen go black for several seconds and is more disruptive.
Conclusion
I would like help in solving the following:
How can I change the cursor in a timely fashion at boot time (Do I need to modify X server or somehow queue events to send once it's reachable?)
How can I ensure a change to the cursor is reflected immediately (as opposed to sometimes waiting until I interact with a UI element)?
More info
Kernel: Linux 5.4.3
Xorg: Version 1.20.5
(1): matchbox-remote.c (in /usr/bin/)
Display *dpy;
...
#include <X11/cursorfont.h>
#include <X11/extensions/Xfixes.h>
...
void set_show_cursor (int show)
{
Window root;
Cursor cursor;
Pixmap bitmap;
XColor color;
static char data[8] = {0};
root = DefaultRootWindow(dpy);
if (!show) {
color.red = color.green = color.blue = 0;
bitmap = xCreateBitmapFromData(dpy, root, data, 8, 8);
cursor = XCreatePixmapCursor(dpy, bitmap, bitmap, &color, &color, 0, 0);
XDefineCursor(dpy, root, cursor);
XFreeCursor(dpy, cursor);
XFreePixmap(dpy, bitmap);
} else {
cursor = XCreateFontCursor(dpy, XC_left_ptr);
XDefineCursor(dpy, root, cursor);
XFreeCursor(dpy, cursor);
}
}
...
static void usage(char *progname) {
...
printf(" -show-cursor [1|0] Enable or disable the cursor\n");
...
}
...
int main (int argc, char* argv[])
{
...
for (i=1; argv[i]; i++) {
...
switch (arg[1])
{
....
case 's':
if (NULL != argv[i+1]) {
set_show_cursor(atoi(argv[i+1]));
}
break;
...
}
}
XSync(dpy, False);
XCloseDisplay(dpy);
}
(2): 98-cursor-toggle.rules (in /etc/udev/rules.d)
SUBSYSTEMS="usb", ACTION=="add", ENV{ID_INPUT_MOUSE}=="1", RUN+="/bin/sh -c 'DISPLAY=:0 /usr/bin/matchbox-remote -show-cursor 1'"
SUBSYSTEMS="usb", ACTION=="remove", ENV{ID_INPUT_MOUSE}=="1", RUN+="/bin/sh -c 'DISPLAY=:0 /usr/bin/matchbox-remote -show-cursor 0'"
(3) cursor-init.service (in /lib/systemd/system)
[Unit]
Description=X11 cursor initialisation
After=multi-user.target
Requires=multi-user.target
[Service]
Type=simple
ExecStart=/bin/sh -c 'DISPLAY=:0 /usr/bin/matchbox-remote -show-cursor $(ls -1 /dev/input/by-*/*-mouse 2>/dev/null | wc -l)'
RemainAfterExit=true
StandardOutput=journal
Restart=on-failure
RestartUSec=500000
[Install]
WantedBy=graphical.target

Why fonts are cutten above the "ascender" line on a Qt application running on embedded linux?

UPDATE
After other tests i verified that this issue below is related to some problem in the rendering of the font.
So in the end i chose a simpler solution: i edited the font moving the "ascender" line upper in a way that now all the symbols are under this line. And now i can see alle the symbols correctly!
===========================================================================
I have some problems to correctly visualize the font Helvetica Neue LT Std Font on an embedded device. The problem is that i can't see the part of a character that is in the ascender area of the font, for example i can't see the accent of the char "À". But also for example the symbol ^ above the char "ê" is cutten. Checking the font with fontdrop.info i can confirm that the parts of the characters that are cutten are the parts in the ascender area.
If i run the application on PC, it works fine.
My embedded device is based on a iMx6 ULL processor. The screen resolution is 800x480.
Meaning of "ascender area"
I verified that the font that is displayed is the correct one. I tried to edit the font moving the symbol above the "À" under the "ascender" line and in this way the symbol is visible. So i can confirm that the problem is in the visualization of the symbols or of the parts of a character that is in the ascender area.
main.cpp
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QFont>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
QFont font("HelveticaNeueLTStd");
// font.setStretch(QFont::Condensed);
app.setFont(font);
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}
main.qml
import QtQuick 2.6
import QtQuick.Window 2.2
Window {
visible: true
width: 800
height: 480
// FontLoader { id: fixedFont; name: "HelveticaNeueLTStd" }
Text {
id: textEdit
text: qsTr("212Àê\u222B")
font.pointSize: 24
verticalAlignment: Text.AlignVCenter
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 20
// font.family: fixedFont.name
}
}
PC vs Embedded example
Maybe is not a Qt problem but is a problem in some configuration of fonts management on my embedded system? Please Help!

resource IDs in VC++

I define resource IDs as below:
#define _RESOURCE_ID 150
#define IDR_OPBUTTON _RESOURCE_ID + 10
When I use below code to change the text of button, it doesn't work:
SetDlgItemText(hWnd, IDR_OPBUTTON, _T("-"));
But if I give it a number directly, it does work:
#define IDR_OPBUTTON 160
Can anybody tell me why? Thanks in advance!
Also, I tried function GetDlgItemInt for a textbox, it has the same behavior.
Did you try to put parenthesis?
#define IDR_OPBUTTON (_RESOURCE_ID + 10)

Different window's border color using NCurses

I have couple of NCurses windows running in terminal. Is it possible to set other border color for each window? I tried code below, but it doesn't work:
start_color()
// ...
init_pair (1, COLOR_RED, COLOR_CYAN);
attron (COLOR_PAIR (1));
box (window, 0,0);
wrefresh (window);
attroff (COLOR_PAIR (1));
you can set a COLOR_PAIR for the entire window like this:
wbkgd(WINDOW* your_window,COLOR_PAIR(nb_of_you_pair))
For setting color for the box only do:
wattron(win,COLOR_PAIR)
box(win,0,0)
wattroff(win,COLOR_PAIR)

Problems encountered in changing a CRichEditCtrl selection color

I have written the following code after creating the CRichEditCtrl
// 06112010 : The following code was added to highlight the textselection in black color instead of the default blue color of CRichEditCtrl. - 1311
{
m_EditControl.SetSel(0,100);
CHARFORMAT2 cf1;
cf1.cbSize = sizeof(CHARFORMAT2);
m_EditControl.GetSelectionCharFormat(cf1);
cf1.dwMask = CFM_BACKCOLOR ;
cf1.dwEffects &= ~CFE_AUTOBACKCOLOR;
cf1.crBackColor = RGB(0,0,0);
m_EditControl.SetSelectionCharFormat(cf1);
m_EditControl.Invalidate();
}
After this I am adding text, but the selection still comes in blue color instead of Black. Could someone please tell me what I am doing wrong??
Thanks,
DeV
You can't do it using SetSelectionCharFormat, which will only reformat the selected text. What you're asking for is an owner draw rich edit control, which is going to be more work than just deriving your own custom window from CWnd and implementing your own WM_PAINT handler.

Resources