Gdm3 Does Not Honour X Server Font Settings

I have just upgraded to using Gdm3 on my Debian machines. I quickly noticed that the font path setting specified in my /etc/X11/xorg.conf file was not being honoured. I use a font server and have "unix/:7100" as my font path.

However sometimes upon first login the font path was set to just a list of hard-wired font paths. If I logged out and then back in again all was well. This never happened when using Gdm.

I concluded that there was probably some sort of race condition where the X server started querying the font server before it was ready and then fell back to its default font path when it got no response from the font server. I therefore wrote a login script that made sure the font server was responding before proceeding.

The Bourne shell script that I used is here:

# This file is sourced by Xsession(5), not executed.

# Test to see if the font server is running and then wait for it to respond.

count=0
ok=0
while test $count -lt 20 -a $ok -eq 0
do
    (netstat --unix -l | fgrep -q 7100) > /dev/null 2>&1
    if test $? -ne 0
    then
        sleep 1
    else
        ok=1
    fi
    count=`expr $count + 1`
done
if test $ok -ne 0
then
    xset fp= 'unix/:7100' > /dev/null 2>&1
else
    xset fp default > /dev/null 2>&1
fi
xset fp rehash > /dev/null 2>&1
xlsfonts > /dev/null 2>&1
unset count ok

The while loop at line 7 waits for a listening unix socket on 7100 to appear on the system (this is the socket that the X font server uses by default). If no socket is found then it gives up after 20 seconds.

The rest of the script from line 18 then sets the font path according to whether it could find a font server or not (using fp default resets the font path to the X server’s built-in fall-back setting). The xlsfonts command at line 25 is there to make sure that any font source is responding before proceeding (if the X font server has created the socket but has not finished initialising then this statement will block until it starts to respond with font data). I lastly unset the variables that I have created as this script is sourced rather than run in a separate process.

I then installed this script as /etc/X11/Xsession.d/10x11-font-path. However this is probably distribution specific, as on say RHEL 4 I would have put this script under /etc/X11/xinit/xinitrc.d.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s