Set xterm font size depending on screen resolution?


I’ve got what seems like a simple problem, but I haven’t been able to find a solution (maybe I’m searching on the wrong things?), though somewhat similar things seem to suggest it’s possible.

I have a very minimalist setup, just a few xterm windows & a pager on startup. I usually use an external 1600x1200 display, but occasionally need to use the laptop screen alone (1400x1050), or an overhead projector (usually 1024x768). When I do, the specified xterm font size makes the windows way too big. What I’d like is some way to get the resolution on startup (I think $[vp.width] &c will do this?), and then something like

if ($[vp.width] == 1600)
font = 8x16;
else if ($[vp.width == 1400)
font = 7x14; etc…

Then in the InitFunction section have

  • “I” Exec xterm -$font (other parameters)

So the net effect would be that I would have windows occupying about the same parts of the screen real estate, just using a coarser font at lower resolutions. Anyone know of good solution to this? Simple if possible, since I’ve never gotten into complex scripting.


AddToFunc StartFunction I PipeRead `[ $[vp.width] = 1600 ] && echo "Exec exec xterm -fn 8x16" || [ $[vp.width] = 1400 ] && echo "Exec exec xterm -fn 7x14" ]`

– Thomas Adam

Thanks. I don’t quite understand the command syntax inside the piperead command, but from the man page, it looks like I ought to be able to just call a program with $[vp.width] as an argument, and have the program write whatever FMWM commands I want to stdout? So I could just put e.g.

AddToFunc StartFunction I PipeRead windowsetup $[vp.width]

and then get as elaborate as I want to in the windowsetup program?

Yes – but if you’re doing anything elaborate, you should consider using FvwmPerl to do it.

– Thomas Adam