Solved Changing font size in XTerm after defining a list in ~/.Xresources

Solved issue

Trenix25

Well-Known Member
Joined
Aug 15, 2017
Messages
600
Reaction score
327
Credits
5,469
This is my ~/.Xresources file:

Code:
xterm*faceName: Terminus
xterm*faceSize: 18
xterm*faceSize1: 8
xterm*faceSize2: 10
xterm*faceSize3: 12
xterm*faceSize4: 14
xterm*faceSize5: 16
xterm*faceSize6: 18
xterm*geometry: 135x37
xterm*rightScrollBar: true
xterm*saveLines: 1024
xterm*scrollBar: true
xterm*scrollTtyOutput: false
xterm*selectToClipboard: true
xterm*Background: black
xterm*Foreground: white
xterm*VT100.Translations: #override <Key>F11: smaller-vt-font() <Key>F12: larger-vt-font()

Bing's CoPilot told me to add that last line so I could use F11 and F12 to change the font size in my XTerm in KDE5 Plasma in Debian 11 Linux. Neither key is working. It just prints a ~ instead. If I use Control-(Right Mouse Button) a small menu tries to pop up, but doesn't quite make it. I'm supposed to be able to use the mouse pointer to select the new font size somehow, but often times the list simply isn't there. Wouldn't you know it, as soon as I tried writing this post it started working in one of my XTerms, but not in another. How do I dynamically change the font size in XTerm without changing ~/.Xresources every time I want to change the font size? I need to log in once, open some XTerms and then change the font size in four of them. I want to get four XTerms on one virtual console in KDE5 so I can use ssh to connect to another computer on a local network and have all four on the same screen. I managed to get I think 69x18 in each of them and got them all lined up, but I need at least 80x24 so I'll need to tinker with the font size. I need something that I can run on the command line without some seriously complicated shell script. CoPilot tried to tell me about xrdb, but it didn't seem to do anything. The -query option was helpful, but the -merge option doesn't seem to help. I need the ~/.Xresources file to stay the same after logging in. The primary XTerm geometry needs to be 135x37 so I get a full screen XTerm, well not "full screen" exactly, but you get the idea. It will fill the display. Then other XTerms that will be started later will need to be resized to use a different font size and window size so I can fit four XTerms on the same virtual console and fill the display. I just went around and around with Bing's CoPilot without success. It just kept saying the same things that weren't working for me.

Signed,

Matthew Campbell
 


This is my ~/.Xresources file:

Code:
xterm*faceName: Terminus
xterm*faceSize: 18
xterm*faceSize1: 8
xterm*faceSize2: 10
xterm*faceSize3: 12
xterm*faceSize4: 14
xterm*faceSize5: 16
xterm*faceSize6: 18
xterm*geometry: 135x37
xterm*rightScrollBar: true
xterm*saveLines: 1024
xterm*scrollBar: true
xterm*scrollTtyOutput: false
xterm*selectToClipboard: true
xterm*Background: black
xterm*Foreground: white
xterm*VT100.Translations: #override <Key>F11: smaller-vt-font() <Key>F12: larger-vt-font()

Bing's CoPilot told me to add that last line so I could use F11 and F12 to change the font size in my XTerm in KDE5 Plasma in Debian 11 Linux. Neither key is working. It just prints a ~ instead. If I use Control-(Right Mouse Button) a small menu tries to pop up, but doesn't quite make it. I'm supposed to be able to use the mouse pointer to select the new font size somehow, but often times the list simply isn't there. Wouldn't you know it, as soon as I tried writing this post it started working in one of my XTerms, but not in another. How do I dynamically change the font size in XTerm without changing ~/.Xresources every time I want to change the font size? I need to log in once, open some XTerms and then change the font size in four of them. I want to get four XTerms on one virtual console in KDE5 so I can use ssh to connect to another computer on a local network and have all four on the same screen. I managed to get I think 69x18 in each of them and got them all lined up, but I need at least 80x24 so I'll need to tinker with the font size. I need something that I can run on the command line without some seriously complicated shell script. CoPilot tried to tell me about xrdb, but it didn't seem to do anything. The -query option was helpful, but the -merge option doesn't seem to help. I need the ~/.Xresources file to stay the same after logging in. The primary XTerm geometry needs to be 135x37 so I get a full screen XTerm, well not "full screen" exactly, but you get the idea. It will fill the display. Then other XTerms that will be started later will need to be resized to use a different font size and window size so I can fit four XTerms on the same virtual console and fill the display. I just went around and around with Bing's CoPilot without success. It just kept saying the same things that weren't working for me.

Signed,

Matthew Campbell
I'm not sure I can answer the query, but these thoughts arose:

The normal way to resize a font in xterm on the fly, is to hold down the crtl key and the right button on the mouse. A menu should appear for the user to select a font size which is described using these terms: "Default, Unreadable, Tiny, Small, Medium, Large, Huge, Enormous". The default range will follow the configurations in /etc/X11/app-defaults/XTerm, where the actual sizes appear, which however, can be overridden as you have described in the .Xresources file. Dunno if that helps, but it's how I can run multiple xterms using varying fonts on the screen. If the menu of font sizes doesn't appear, as you've mentioned, then perhaps check the XTerm configuration file and note if there are conflicts or formatting issues between those configurations and those you've placed in the .Xresources file.
 
Last edited:
/etc/X11/app-defaults/XTerm appears to be defining these font sizes starting on line 109. I wonder if I should be defining them that way, or the way I did in ~/.Xresources.

Signed,

Matthew Campbell
 
/etc/X11/app-defaults/XTerm appears to be defining these font sizes starting on line 109. I wonder if I should be defining them that way, or the way I did in ~/.Xresources.

Signed,

Matthew Campbell
I guess one way of approaching it is to check out using the defaults in the XTerm file without any of your own relevant configurations in the .Xresources and see if they are satisfactory for your needs. If not, then I guess I'd try and add a single configuration at a time to see what difference they can make to improve things. It's perhaps a laborious business. Personally I use the default sizes, but with the singular config:
Code:
XTerm*faceName: DejaVu Sans Mono
XTerm*faceSize: 12
The crtl+RightMouseButton works perfectly with this for me, enabling all the varying font sizes in that particular font. I can also change the fonts using the keyboard alone with:
shft+"+" and shft+"-" to increase or decrease the font size one step at a time (without the quotes).
 
I have solved this problem by creating a bash script called qterm. It spins out four XTerms using the correct faceSize, geometry, and initial positions on the display. Now I can just call this using krunner with Alt+Space. The Termius font is the font specified in my ~/.Xresources file. This way I don't have to fight with this every time I start this up by changing the font and moving the XTerm windows around to the correct positions. It is much easier this way. I needed at least 80x25, but wound up using 93x27. This was the largest font size (faceSize) that would give me at least 80x25 and still allow four XTerms to be fully visible on the display. My monitor uses a resolution of 1920x1200. Other users may need to tinker with those values depending on their monitor resolution and the sizes of their menu and widget task bars.

Code:
#!/bin/bash
#
# Creates four XTerms using the default Termius font at faceSize 12 on the same screen.

# Using sleep 1 causes the terminal numbers to be allocated in the correct order.

/usr/bin/xterm -fs 12 -geometry 93x27+0+31 &
/usr/bin/sleep 1
/usr/bin/xterm -fs 12 -geometry 93x27+956+31 &
/usr/bin/sleep 1
/usr/bin/xterm -fs 12 -geometry 93x27+0+589 &
/usr/bin/sleep 1
/usr/bin/xterm -fs 12 -geometry 93x27+956+589 &

exit 0

# EOF

Screenshot_20241206_103712.png


Using sleep 1 guarantees that the terminal numbers are allocated by the system in the correct order, otherwise the numbers could get a little jumbled and I need it to be orderly. Unfortunately XTerm cannot be just any size the user wants it to be, but must be sized in such a way as to use an integer number of lines and columns without extra unused screen space. As such I was not able to totally cover the display to prevent the wallpaper from being visible at the right and bottom edges.

Signed,

Matthew Campbell
 
I have solved this problem by creating a bash script called qterm. It spins out four XTerms using the correct faceSize, geometry, and initial positions on the display. Now I can just call this using krunner with Alt+Space. The Termius font is the font specified in my ~/.Xresources file. This way I don't have to fight with this every time I start this up by changing the font and moving the XTerm windows around to the correct positions. It is much easier this way. I needed at least 80x25, but wound up using 93x27. This was the largest font size (faceSize) that would give me at least 80x25 and still allow four XTerms to be fully visible on the display. My monitor uses a resolution of 1920x1200. Other users may need to tinker with those values depending on their monitor resolution and the sizes of their menu and widget task bars.

Code:
#!/bin/bash
#
# Creates four XTerms using the default Termius font at faceSize 12 on the same screen.

# Using sleep 1 causes the terminal numbers to be allocated in the correct order.

/usr/bin/xterm -fs 12 -geometry 93x27+0+31 &
/usr/bin/sleep 1
/usr/bin/xterm -fs 12 -geometry 93x27+956+31 &
/usr/bin/sleep 1
/usr/bin/xterm -fs 12 -geometry 93x27+0+589 &
/usr/bin/sleep 1
/usr/bin/xterm -fs 12 -geometry 93x27+956+589 &

exit 0

# EOF

View attachment 23099

Using sleep 1 guarantees that the terminal numbers are allocated by the system in the correct order, otherwise the numbers could get a little jumbled and I need it to be orderly. Unfortunately XTerm cannot be just any size the user wants it to be, but must be sized in such a way as to use an integer number of lines and columns without extra unused screen space. As such I was not able to totally cover the display to prevent the wallpaper from being visible at the right and bottom edges.

Signed,

Matthew Campbell
Thanks @Trenix25 for the solution. In my own case this sort of arrangement is done with tmux. I guess there are a number of tiling window managers that can achieve it or approximate it as well, but there's often satisfaction in doing it in one's own way too.

On the name "qterm", there already exists a program in the debian repos called qterm, a BBS client for X. It shouldn't matter if you don't download qterm. I'd be inclined to choose a unique name though.
 
I have not installed the tmux or qterm packages. I am using ~/bin/qterm.

Signed,

Matthew Campbell
 

Members online


Top