1 |
#!/bin/sh |
2 |
# Startup script called from /etc/X11/xinit/xinitrc and /etc/X11/xdm/Xsession |
3 |
# to fix keyboard. |
4 |
|
5 |
# NOTE: when opening an X11 session remotely the keyboard must match |
6 |
# the one on the remote display; so we check if there is a keyboard |
7 |
# configured for the particular display first. |
8 |
|
9 |
# to be sure to have xdpyinfo and xmodmap |
10 |
PATH=/usr/bin:$PATH |
11 |
|
12 |
usermodmap=$HOME/.Xmodmap.$DISPLAY |
13 |
userxkbmap=$HOME/.Xkbmap.$DISPLAY |
14 |
[ ! -r "$usermodmap" ] && usermodmap=$HOME/.Xmodmap |
15 |
[ ! -r "$userxkbmap" ] && userxkbmap=$HOME/.Xkbmap |
16 |
|
17 |
sysmodmap=/etc/X11/Xmodmap.$DISPLAY |
18 |
sysxkbmap=/etc/X11/Xkbmap.$DISPLAY |
19 |
if ! xdpyinfo | grep "vendor string" | egrep -v "XFree86|X\.Org" > /dev/null 2>&1; then |
20 |
# Xterminal does not have a XFree86 based server, so avoid |
21 |
# default (= XFree86) maps: |
22 |
[ ! -r "$sysmodmap" ] && sysmodmap=/etc/X11/Xmodmap |
23 |
[ ! -r "$sysxkbmap" ] && sysxkbmap=/etc/X11/xinit/Xkbmap |
24 |
fi |
25 |
# backward compatibility |
26 |
oldsysmodmap=/usr/lib/X11/xinit/.Xmodmap |
27 |
|
28 |
# only test for XKB if user hasn't asked for no |
29 |
[ -x /etc/profile.d/10lang.sh ] && . /etc/profile.d/10lang.sh |
30 |
|
31 |
if [ "$XKB_IN_USE" != "no" ]; then |
32 |
XKB_IN_USE= |
33 |
|
34 |
if xdpyinfo | grep XKEYBOARD > /dev/null 2>&1; then |
35 |
XKB_IN_USE=yes |
36 |
fi |
37 |
fi |
38 |
|
39 |
# merge in keymaps |
40 |
if [ -n "$XKB_IN_USE" -a -r $sysxkbmap ]; then |
41 |
setxkbmap `cat $sysxkbmap` |
42 |
fi |
43 |
|
44 |
if [ -n "$XKB_IN_USE" -a -r $userxkbmap ]; then |
45 |
setxkbmap `cat $userxkbmap` |
46 |
fi |
47 |
|
48 |
if [ -z "$XKB_IN_USE" -a ! -L /etc/X11/X ]; then |
49 |
if grep '^exec.*/Xsun' /etc/X11/X > /dev/null 2>&1 && [ -f /etc/X11/XF86Config ]; then |
50 |
xkbsymbols=`sed -n -e 's/^[ ]*XkbSymbols[ ]*"\(.*\)".*$/\1/p'` |
51 |
if [ -n "$xkbsymbols" ]; then |
52 |
setxkbmap -symbols "$xkbsymbols" |
53 |
XKB_IN_USE=yes |
54 |
fi |
55 |
fi |
56 |
fi |
57 |
|
58 |
# xkb and xmodmap don't play nice together |
59 |
if [ -z "$XKB_IN_USE" ]; then |
60 |
if [ -r $oldsysmodmap ]; then |
61 |
xmodmap $oldsysmodmap |
62 |
fi |
63 |
|
64 |
if [ -r $sysmodmap ]; then |
65 |
xmodmap $sysmodmap |
66 |
fi |
67 |
|
68 |
if [ -r $usermodmap ]; then |
69 |
xmodmap $usermodmap |
70 |
fi |
71 |
fi |
72 |
|
73 |
# fixkeyboard ends here |