You are not logged in.
Pages: 1
I use this in all my font pkgs and to do a general refersh when things get screwed up - it is based on bits from various font pkgs. Run it in a term ideally and don't forget to restart X
#!/bin/bash
basedir=/usr/X11R6/lib/X11/fonts
cd $basedir
echo "Rebuilding font cache..."
fc-cache -fv
echo "...done."
for dir in {TTF,misc,75dpi,Type1,Speedo,100dpi,cyrillic,artwiz-fonts,terminus,lfp-fix,lfp-var,nucleus}
do
echo "Rebuilding font index in $dir..."
cd $dir
mkfontscale
mkfontdir
rm -f encodings.dir
ln -s /usr/X11R6/lib/X11/fonts/encodings/encodings.dir encodings.dir
echo "...done."
cd $basedir
done
echo "Fonts refreshed! Press any key to exit."
read KEY
Offline
I wonder if it would be possible to not restart x if you add xset -fp and xset +fp for each font dir (something like xset -fp ${basedir}/${dir} and then xset +fp ${basedir}/${dir} after reindexing and inside "for")?
EDIT: or fp rehash ?
fp rehash
The rehash argument resets the font path to its current value, causing the server to reread the font databases in the current font path. This is generally only used when adding new fonts to a font directory (after running mkfontdir to recreate the font database).-fp or fp-
The -fp and fp- options remove elements from the current font path. They must be followed by a comma-separated list of entries.+fp or fp+
This +fp and fp+ options prepend and append elements to the current font path, respectively. They must be followed by a comma-separated list of entries.
EDIT2: of course this is not something to be put inside pkgbuild's install file because you may not be running x while running this script. On the other hand it should be possible to detect if you are running x or not and further improve the script (ah perfection...)
Offline
Offline
nice one guys
Offline
#!/bin/bash
# which xserver are we running?
if [ -z "$(pacman -Qi | grep xorg)" ]; then
xconfig=/etc/X11/XF86Config-4
else
xconfig=/etc/X11/xorg.conf
fi
echo "Rebuilding font cache..."
fc-cache -fv
echo "...done."
# grab the font paths from xserver config
FontPath=`cat $xconfig | grep "FontPath .*/" | sed "s|#FontPath .*||g" | sed "s|FontPath||g" | sed "s|"||g" | sed "s|.*:unscaled||g"`
for dir in $FontPath; do
echo "Rebuilding font index in $dir..."
cd $dir
mkfontscale
mkfontdir
rm -f encodings.dir
ln -s /usr/X11R6/lib/X11/fonts/encodings/encodings.dir encodings.dir
echo "...done."
cd $basedir
done
echo "Fonts refreshed! Press any key to exit."
read KEY
improved still no x detect and xset but i'll work on that
phrak - how do i set my $DISPLAY var - it doesn't seem to be set which is screwing up me lauching apps in win from the console
Offline
OK! I finally included your suggestions! I think this script is now as good as lanrat hoped. It now detects if X is running and rehashes if it is. You can now also run the script and provide a specific dir to be updated, this allows it to be included as a function in an install script.
#!/bin/bash
# some colour
colour="33[1;32m"
no_colour="33[1;0m"
# are we root?
if [ "$(whoami)" != "root" ] ; then
echo "You need to run as root!"
exit
fi
# which xserver are we running?
if [ -z "$(pacman -Qi | grep xorg)" ] ; then
xconfig=/etc/X11/XF86Config-4
else
xconfig=/etc/X11/xorg.conf
fi
echo -e "${no_colour}Rebuilding font cache..."
fc-cache -fv
echo
# Grab the font paths from command line (for specific install)
# or xserver config (for general refresh)
if [ -z $1 ] ; then
FontPath=`cat $xconfig | grep "FontPath .*/" | sed "s|#FontPath .*||g" |
sed "s|FontPath||g" | sed "s|"||g" | sed "s|.*:unscaled||g"`
else
FontPath="$1"
fi
for dir in $FontPath ; do
echo -ne "${no_colour}Rebuilding font index in $dir..."
cd $dir
mkfontscale
mkfontdir
rm -f encodings.dir
ln -s /usr/X11R6/lib/X11/fonts/encodings/encodings.dir encodings.dir
[ ! -z $DISPLAY ] && xset fp rehash
echo -e "${colour}done${no_colour}."
done
echo
echo -e "${no_colour}Fonts refreshed! Press any key to exit."
read KEY
I added the colour for fun - easy to remove!
Offline
I didn't write this of course, but I thought I'd update it for xorg7
#!/bin/bash
# some colour
colour="33[1;32m"
no_colour="33[1;0m"
# are we root?
if [ "$(whoami)" != "root" ] ; then
echo "You need to run as root!"
exit
fi
# which xserver are we running?
if [ -z "$(pacman -Qi | grep xorg)" ] ; then
xconfig=/etc/X11/XF86Config-4
else
xconfig=/etc/X11/xorg.conf
fi
echo -e "${no_colour}Rebuilding font cache..."
fc-cache -fv
echo
# Grab the font paths from command line (for specific install)
# or xserver config (for general refresh)
if [ -z $1 ] ; then
FontPath=`cat $xconfig | grep "FontPath .*/" | sed "s|#FontPath .*||g" |
sed "s|FontPath||g" | sed "s|"||g" | sed "s|.*:unscaled||g"`
else
FontPath="$1"
fi
for dir in $FontPath ; do
echo -ne "${no_colour}Rebuilding font index in $dir..."
cd $dir
mkfontscale
mkfontdir
rm -f encodings.dir
ln -s /usr/share/fonts/encodings/encodings.dir encodings.dir
[ ! -z $DISPLAY ] && xset fp rehash
echo -e "${colour}done${no_colour}."
done
echo
echo -e "${no_colour}Fonts refreshed! Press any key to exit."
read KEY
-Connor McKay
"He is no fool who gives what he cannot keep to gain what he cannot lose" - Jim Elliot
Offline
Pages: 1