valadil
valadil

Reputation: 1703

How do I figure out what font a running urxvt is using?

I found some escape codes for changing fonts in urxvt. I'd like to use these to dynamically change my font size. I've seen a few plugins that do this, but they're fairly opinionated about it and usually rely on a hardcoded list of fonts to toggle through. I'd prefer to query for the current font, change the size, and print the escape codes for that. Is this possible?

Upvotes: 3

Views: 5074

Answers (2)

user34445
user34445

Reputation: 191

Press Control-Shift and click a character.

A small window will appear telling you what the font is for the character you clicked.

Upvotes: 9

Micah Elliott
Micah Elliott

Reputation: 10274

You can use appres to query the font. Not sure what Linux you’re on, but if it happens to be Arch, install with: sudo pacman -S xorg-appres.

Example query on my system:

% appres urxvt |grep '\*font:' |awk '{print $2}'
-misc-orp-medium-r-*-*-12-*-75-75-*-60-iso10646-*

You could parse out the size info (12) from that to decide whether to increase or whatever:

% origsize=$(appres urxvt |grep '\*font:' |awk -F- '{print $8}')  # 12

You can use printf to increase that size, in a my-font-changer script, like:

printf "\033]710;-misc-orp-medium-r-*-*-$newsize-*-*-*-*-*-iso8859-*\007"
printf "\033]711;-misc-orp-bold-*-*-*-$newsize-*-*-*-*-*-iso8859-*\007"
printf "\033]712;-misc-orp-*-i-*-*-$newsize-*-*-*-*-*-iso8859-1\007"
printf "\033]713;-misc-orp-*-i-*-*-$newsize-*-*-*-*-*-iso8859-1\007"

Then you could assign a hotkey in ~/.Xdefaults:

URxvt.keysym.M-C-1: command: my-font-changer

(Most of this is untested, but you can piece it together.)

Upvotes: 3

Related Questions