Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Font Config Script
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Hackeron
Guru
Guru


Joined: 01 Nov 2002
Posts: 307

PostPosted: Mon Mar 01, 2004 5:00 pm    Post subject: Font Config Script Reply with quote

Just practicing bash scripting alittle, anyway, this is a script to configure fonts based on information in:

https://forums.gentoo.org/viewtopic.php?t=129039&highlight=font
and https://forums.gentoo.org/viewtopic.php?t=76503

give me your opinion and post any suggestions.

Quote:

#!/bin/bash
#Font Config script V2

source /sbin/functions.sh

XF86CONFIG=/etc/X11/XF86Config
FONTCONF=/etc/X11/fs/config
LOCALCONF=/etc/fonts/local.conf
ADDLINES="/usr/share/fonts/corefonts, /usr/share/fonts/freefont" # Lines to add to $FONTCONF
ADDLINES2="<dir>/usr/share/fonts</dir> <dir>/usr/X11R6/lib/X11/fonts/truetype</dir>" # Lines to add to $LOCALCONF
PACKAGES='sharefonts freefonts gtk-theme-switch'
PACKAGESMASK='corefonts'
EXCLUDE="R|D" # Exclude when package needs to be downgraded or re-installed.


#####################################
# STAGE 1 = editing XF86Config file if nvidia driver is being used
#####################################
[ ! "$(cat $XF86CONFIG | grep Hackeron)" ] && cp $XF86CONFIG /etc/X11/XF86Config.orig

if [ "$(cat $XF86CONFIG | grep " "*Driver.*\"nvidia\")" ]; then
if [ ! "$(cat $XF86CONFIG | grep " "*Option.*\"NoDDC\".*\"true\" | grep -v \#)" ]; then
perl -pe 'if($seen==1){if(/EndSection/){print "\tOption \"NoDDC\" \"true\" \# Added by Hackeron\n"; $seen=2; }}$seen=1 if(/Section "Monitor"/);' /etc/X11/XF86Config.orig > $XF86CONFIG
fi
fi

#####################################
# STAGE 2 = emerging all packages required for truetype fonts, feel free to add to the packages and packgesmask lists
#####################################
for package in $PACKAGES
do
if [ "$(emerge -p "$package" | tail -n 2 | awk '{ print $2 }' | egrep -v $EXCLUDE)" ]; then
ebegin "Emerging $package"
emerge -k "$package" &> /dev/null && eend || eend -1 || exit 0
fi
done

for maskpackage in $PACKAGESMASK
do
if [ "$(ACCEPT_KEYWORDS="~x86" emerge -p "$maskpackage" | tail -n 2 | awk '{ print $2 }' | egrep -v $EXCLUDE)" ]; then
ebegin "Emerging $maskpackage"
ACCEPT_KEYWORDS="~x86" emerge -k "$maskpackage" &> /dev/null && eend || eend -1 || exit 0
fi
done

######################################
# STAGE 3 = editing $FONTCONF
######################################
for addline in $ADDLINES; do
LASTLINE=$(cat $FONTCONF | grep \/fonts\/ | tail -1 | sed 's/\//\\\//g')
if [ ! "$(echo "$LASTLINE" | grep ,$)" ]; then
sed "s/$LASTLINE/$LASTLINE,/" -i $FONTCONF
fi

if [ ! "$(cat "$FONTCONF" | grep "$addline")" ]; then
sed "/$LASTLINE/a $addline" -i "$FONTCONF"
fi
done

######################################
# STAGE 4 = editing $LOCALCONF and font.conf
######################################
LASTLINE="$(cat "$LOCALCONF" | grep '\-\->' | tail -1)"

for addline in $ADDLINES2; do
if [ ! "$(cat "$LOCALCONF" | grep "$addline")" ]; then
sed "/^$LASTLINE/a $addline" -i "$LOCALCONF"
fi
done

# get rid of the 75/100dip font paths as suggested.
cp /etc/fonts/fonts.conf /etc/fonts/fonts.conf.backup
sed 's/<dir>\/usr\/X11R6\/lib\/X11\/fonts\/75dpi<\/dir>//' -i /etc/fonts/fonts.conf
sed 's/<dir>\/usr\/X11R6\/lib\/X11\/fonts\/100dpi<\/dir>//' -i /etc/fonts/fonts.conf

######################################
# STAGE 5 = xfs start/stop
######################################
/etc/init.d/xfs start
/etc/init.d/xfs stop
fc-cache -fv
Back to top
View user's profile Send private message
bigsmoke
Tux's lil' helper
Tux's lil' helper


Joined: 09 Aug 2003
Posts: 92
Location: The city of Groningen in The Netherlands

PostPosted: Wed Mar 03, 2004 2:57 am    Post subject: Nice script Reply with quote

Nice script. Now if only I'd understand already how the XF86Config, the XFtconfig and /etc/fonts/fonts.config interlock :?
_________________
Gentoo's kind community
has build up an immunity
for the kind of rash
that makes others bash(1)
the newer GNU/Linux user,
a man(1) that is inapt
to flawlessly adapt,
and therefore called a luser.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum