Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Setting terminal’s font and font size in script.

107 views
Skip to first unread message

hongy...@gmail.com

unread,
Jan 2, 2021, 9:23:01 PM1/2/21
to
I want to set the following font and specific font size, say, 14 for my GNOME Terminal in script:

$ fc-list | grep -i 'dejavusansmono nerd font mono.*book'
/home/werner/.local/share/fonts/NerdFonts/DejaVu Sans Mono Nerd Font Complete Mono.ttf: DejaVuSansMono Nerd Font Mono:style=Book

Any hints for doing this programmatically within script?

Regards,
HY

Grant Taylor

unread,
Jan 2, 2021, 9:28:49 PM1/2/21
to
On 1/2/21 7:22 PM, hongy...@gmail.com wrote:
> I want to set the following font and specific font size, say, 14 for
> my GNOME Terminal in script:
...
> Any hints for doing this programmatically within script?

Are you talking about starting a GNOME Terminal with a specific profile?
Or are you wanting to change the font of a running GNOME Terminal?



--
Grant. . . .
unix || die

Bit Twister

unread,
Jan 2, 2021, 10:01:17 PM1/2/21
to
Use a "case" statement or if, then, else statements to set a variable
name, then tell gnome-terminal to use $variable_name.

putting
gnome-terminal font command line
in the first box at
https://www.google.com/advanced_search
gets me
About 2,610,000 results (0.85 seconds)

xlsfonts is easy way to list font names.
xfontsel to look at fonts.

Personally I find xterm much more command line friendly for customization.

hongy...@gmail.com

unread,
Jan 3, 2021, 1:44:25 AM1/3/21
to
The former.

hongy...@gmail.com

unread,
Jan 3, 2021, 2:03:00 AM1/3/21
to
On Sunday, January 3, 2021 at 11:01:17 AM UTC+8, Bit Twister wrote:
> On Sat, 2 Jan 2021 18:22:57 -0800 (PST), hongy...@gmail.com wrote:
> > I want to set the following font and specific font size, say, 14 for my GNOME Terminal in script:
> >
> > $ fc-list | grep -i 'dejavusansmono nerd font mono.*book'
> > /home/werner/.local/share/fonts/NerdFonts/DejaVu Sans Mono Nerd Font Complete Mono.ttf: DejaVuSansMono Nerd Font Mono:style=Book
> >
> > Any hints for doing this programmatically within script?
> Use a "case" statement or if, then, else statements to set a variable
> name, then tell gnome-terminal to use $variable_name.
>
> putting
> gnome-terminal font command line
> in the first box at
> https://www.google.com/advanced_search
> gets me
> About 2,610,000 results (0.85 seconds)

Thanks for your valuable notes. I figured out the following solution based on the searching result from <https://ncona.com/2019/11/configuring-gnome-terminal-programmatically/>:

$ GNOME_TERMINAL_PROFILE=`gsettings get org.gnome.Terminal.ProfilesList default | awk -F \' '{print $2}'`
$ gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:$GNOME_TERMINAL_PROFILE/ font 'DejaVuSansMono Nerd Font Mono book 14'


> xlsfonts is easy way to list font names.

I tried this command but it can't list the above font installed on my box:

werner@X10DAi:~$ xlsfonts | grep -i dejavu
werner@X10DAi:~$

> xfontsel to look at fonts.

This tool seems so ugly and still can't list the font mentioned above for my case.

> Personally I find xterm much more command line friendly for customization.

I've learned that tmux is powerful and high customizable, but I haven't tried it till now.

Bit Twister

unread,
Jan 3, 2021, 2:56:28 AM1/3/21
to
Yeah, and it is not so obvious in its usage. You change the fields
to get something to look at. :(

hongy...@gmail.com

unread,
Jan 3, 2021, 9:28:13 AM1/3/21
to
Nowadays, maybe the fc-* commands listed below are more appropriate and convenient for such a job.

$ fc-[<TAB>]
fc-cache fc-conflist fc-match fc-query fc-validate
fc-cat fc-list fc-pattern fc-scan

Bit Twister

unread,
Jan 3, 2021, 2:18:40 PM1/3/21
to
On Sun, 3 Jan 2021 06:28:08 -0800 (PST), hongy...@gmail.com wrote:


> Nowadays, maybe the fc-* commands listed below are more appropriate and convenient for such a job.
>
> $ fc-[<TAB>]
> fc-cache fc-conflist fc-match fc-query fc-validate
> fc-cat fc-list fc-pattern fc-scan
>

Hehe, only if you knew about them.

For any lurkers, run the command
man -k font

Keith Thompson

unread,
Jan 3, 2021, 4:47:05 PM1/3/21
to
"hongy...@gmail.com" <hongy...@gmail.com> writes:
> On Sunday, January 3, 2021 at 11:01:17 AM UTC+8, Bit Twister wrote:
[...]
>> Personally I find xterm much more command line friendly for customization.
>
> I've learned that tmux is powerful and high customizable, but I
> haven't tried it till now.

tmux does not deal with fonts.

--
Keith Thompson (The_Other_Keith) Keith.S.T...@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */
0 new messages