urxvt-ttfont

Submitted scripts and programs
Forum rules
Your own work only.
User avatar
Alad
should take a shower
Posts: 447
Joined: Wed May 21, 2014 12:52 am

urxvt-ttfont

Unread post by Alad » Tue Jul 15, 2014 5:53 pm

Was playing with fonts and got fed up typing "ls /usr/share/fonts", "nano .Xresources" and "xrdb ~/.Xresources" besides restarting the terminal. So quick little script - stolez the license from pidsley while I was it (plus gave it a nice name. :) ).

Code: Select all

#!/bin/bash
#
# GTFO license:
# this program is provided with NO GUARANTEE and NO SUPPORT 
# if it breaks or does not do what you want, FIX IT YOURSELF

# Vars
FONTPATH="/usr/share/fonts/TTF"
FONTS+=($(ls $FONTPATH | awk -F. '{print $1}'))
FONTDEF="xft:DejaVuSansMono-10" # Dirty hack

# Select font
select FONTNEW in "${FONTS[@]}"; do
	read -rp "Enter the font size. " FONTSIZE
	break
done
 
XRES="xft:$FONTNEW-$FONTSIZE" 
printf '\e]710;%s\007' "$XRES" # https://gist.github.com/livibetter/7178625

# LOREM IPSUM
echo \"On the other hand, we denounce with righteous indignation and dislike men 
echo who are so beguiled and demoralized by the charms of pleasure of the moment, 
echo so blinded by desire, that they cannot foresee the pain and trouble that are 
echo bound to ensue\; and equal blame belongs to those who fail in their duty through 
echo weakness of will, which is the same as saying through shrinking from toil and pain.
echo
echo These cases are perfectly simple and easy to distinguish. In a free hour, when our 
echo power of choice is untrammelled and when nothing prevents our being able to do what 
echo we like best, every pleasure is to be welcomed and every pain avoided. But in certain 
echo circumstances and owing to the claims of duty or the obligations of business it will 
echo frequently occur that pleasures have to be repudiated and annoyances accepted.
echo
echo The wise man therefore always holds in these matters to this principle of selection: 
echo he rejects pleasures to secure other greater pleasures, or else he endures pains 
echo to avoid worse pains.\"
echo

xsave() {
	if grep "^URxvt.*font" ~/.Xresources; then
		sed -i "s|^URxvt.*font.*|URxvt.font: $XRES|" ~/.Xresources
	else
		echo "URxvt.font: $XRES" >> ~/.Xresources
	fi
	xrdb ~/.Xresources
}

read -rp "Save the font configuration? [y/n]" OPT
case $OPT in
	[yY]) xsave;;
	[nN]) printf '\e]710;%s\007' "$FONTDEF";;
esac
Last edited by Alad on Tue Jul 15, 2014 7:25 pm, edited 1 time in total.
It's funny how we used to be able to do real stuff with rudimentary computers, but now we can't. -- ratcheer

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: urxvt-font

Unread post by machinebacon » Tue Jul 15, 2014 6:14 pm

Thank you.

Debian users change the font path FONTPATH="/usr/share/fonts/TTF" to FONTPATH="/usr/share/fonts/truetype"
..gnutella..

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: urxvt-ttfont

Unread post by rhowaldt » Tue Jul 15, 2014 9:12 pm

aah cool, i never did much shit with fonts and such precisely for this reason. good job making a script for it :)
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

Post Reply