vidcontrol font and color via /etc/rc.conf problem

Hi there,

I've just compiled brand new FreeBSD 13-STABLE on my home server with vt(4) driver. Since the stock console font is too large for me I want to set a smaller one. I also use lightgreen foreground color for years.
What I want to achieve? Set the vgarom-8x16 font and lightgreen color during system start on all consoles.
Here's my problem.
In the /etc/rc.conf I set allscreens_flags as follows:

Code:
allscreens_flags="-f vgarom-8x16 lightgreen"
It doesn't work.

Code:
allscreens_flags="lightgreen -f vgarom-8x16"
It doesn't work as well.

Running vidcontrol(8) command by hand it also doesn't work to set font and foreground color at once.
So, configuring these two options in /etc/rc.conf file is not working. If I set only font or only color, then it works.
When it's combined, it doesn't.
As a workaround I created simple rc start script I put in /usr/local/etc/rc.d directory to change a foreground color, when the font is configured in /etc/rc.conf.
I do not want to configure color in the /boot/loader.conf because it hurts a little color in Midnight Commander.
Any suggestions?

My server: HP ProLiant MicroServer Gen10 Plus. I'm connecting to server via Java Web Console plugin from HP iLO5 Advanced.
Huh! There is another problem I don't know how to fix. Here I can not to change screen resolution to any other resolutions as of square pixels 4x3. Well, I can live with that, but any other resolutions set in /boot/loader.conf, for example:
Code:
efi_max_resolution="1440x900"
just doesn't work. Maybe it's Java related problem?

Best regards,
Mariusz
 
Last edited by a moderator:
We're talking about the hardware console of the server, right? If we're not, then everything I'm writing below may be irrelevant.

Maybe it's Java related problem?
Pretty much guaranteed to have nothing to do with Java. Why? Because the vidcontrol program and all the scripts in /etc that run it are part of base, and Java is not part of base, so it is not used for this functionality at all.

Running vidcontrol command by hand it also doesn't work to set font and foreground color at once.
So you are saying that "vidcontrol lightgreen" works, and "vidcontrol -f vga..." works?
That is very surprising. Here's why: If you look at "man vidcontrol", you see that setting the foreground color requires the "-r" flag. If you don't use any flag at all, the parameter (in your case lightgreen) is interpreted as a mode, and lightgreen is not a valid mode.

For starters, try "-r lightgreen black" or something similar as argument. Then try combining -r and -f together.

If it is really true that vidcontrol can't take both color and font arguments on a single command line, then you have a problem. Read /etc/rc.d/syscons, and you can see that there is really only one place where you can call vidcontrol with arbitrary arguments. You may have to create a new service (call it syscons_mariusz) that is more flexible, put it in /usr/local/etc, and use it instead. And file a PR, that this would be a useful feature.

But my hunch is that with careful selection of parameters it can be made to work.
 
What I want to achieve? Set the vgarom-8x16 font and lightgreen color during system start on all consoles.
Here's my problem.
In the /etc/rc.conf I set allscreens_flags as follows:

Code:
allscreens_flags="-f vgarom-8x16 lightgreen"
It doesn't work.

Code:
allscreens_flags="lightgreen -f vgarom-8x16"
It doesn't work as well.

Running vidcontrol(8) command by hand it also doesn't work to set font and foreground color at once.
So, configuring these two options in /etc/rc.conf file is not working. If I set only font or only color, then it works.
When it's combined, it doesn't.
As a workaround I created simple rc start script I put in /usr/local/etc/rc.d directory to change a foreground color, when the font is configured in /etc/rc.conf.
I do not want to configure color in the /boot/loader.conf because it hurts a little color in Midnight Commander.
Any suggestions?
You were very close! Check out the usage for vidcontrol.

Code:
vidcontrol [-Cx] [-b color] [-c appearance] [-f [[size] file]]
                  [-g geometry] [-h size] [-i active | adapter | mode]
                  [-M char] [-m on | off]
                  [-r foreground background] [-S on | off] [-s number]
                  [-T xterm | cons25] [-t N | off] [mode]
                  [foreground [background]] [show]

In principle the -f option can take 0, 1, or 2 arguments. (No arguments sounds odd but it's explained in vidcontrol(1) that when using vt, it reverts you to the default font and size. For example try vidcontrol -f gallant followed by vidcontrol -f... assuming your default font isn't gallant.) You're trying it with 1 argument because the font file vgarom-8x16 contains enough information to find the correct file anyway, so the size argument should be unnecessary. But if you try vidcontrol -f vgarom-8x16 show, which should set the font and then show the colors and their numbering, we get the error vidcontrol: show: can't load font file. So here's your problem: when you provide two arguments after -f, they're being parsed as the size and file options. But the size option doesn't matter. Try vidcontrol -f bananafizzbuzz vgarom-8x16 show and (1) the font is changed, (2) the colors are displayed. Perfect! Probably safer and less mystifying to write 8x16 there. Put the following in your rc.conf(5) and you'll be good to go.

Code:
allscreens_flags="-f 8x16 vgarom-8x16 lightgreen"

You can write the background colour too if you want, as well as setting other options like the number of lines of history in the scrollback buffer. The -h option is less problematic because it is always followed by exactly one argument. But following the usage, you do need to put the stuff with flags first and the foreground and background colors last.

Code:
allscreens_flags="-f 8x16 vgarom-8x16 -h <nice big number> lightgreen black"

So you are saying that "vidcontrol lightgreen" works, and "vidcontrol -f vga..." works?
That is very surprising. Here's why: If you look at "man vidcontrol", you see that setting the foreground color requires the "-r" flag. If you don't use any flag at all, the parameter (in your case lightgreen) is interpreted as a mode, and lightgreen is not a valid mode.
The -r is to set the foreground (and background) colors for the reverse mode. For the main background and colours you don't want to use -r. As the man page says, that final [foreground [background]] [show] part of the usage, after all the flags, is to:
Change colors when displaying text. Specify the foreground color (e.g., “vidcontrol white”), or both a foreground and background colors (e.g., “vidcontrol yellow blue”). Use the show command below to see available colors.
If you type e.g. vidcontrol foo this looks ambiguous, but foo needs to be either a valid video mode, a valid foreground colour, or "show" for the command to do anything - and these options are mutually exclusive, so if you read the source you can see how it works out which case we're in. Clearly lightgreen isn't a valid video mode, but it is one of the 16 valid colors listed in legal_colors in the source code.

Code:
static const char *legal_colors[16] = {
    "black", "blue", "green", "cyan",
    "red", "magenta", "brown", "white",
    "grey", "lightblue", "lightgreen", "lightcyan",
    "lightred", "lightmagenta", "yellow", "lightwhite"
};

Oddly these colour names, as displayed by vidcontrol show, don't match the man page: "white" and "lightwhite" are respectively described as "Light Grey" and "White".
 
Back
Top