5 * Common Desktop Environment (CDE)
7 * Common code for dtlogin config scripts
9 * (c) Copyright 1996 Digital Equipment Corporation.
10 * (c) Copyright 1993,1994,1996 Hewlett-Packard Company.
11 * (c) Copyright 1993,1994,1996 International Business Machines Corp.
12 * (c) Copyright 1993,1994,1996 Sun Microsystems, Inc.
13 * (c) Copyright 1993,1994,1996 Novell, Inc.
14 * (c) Copyright 1996 FUJITSU LIMITED.
15 * (c) Copyright 1996 Hitachi.
16 * (c) Copyright 1997, The Open Group.
18 * $TOG: _common.ksh.src /main/12 1998/05/13 17:48:34 rafi $
25 * Note: this file is included by Xsession.src and Xsetup.src. If
26 * Xsession is being built, cpp_Xsession will be defined. If Xsetup
27 * is being built, cpp_Xsetup will be defined.
33 HASH Determine Xsession parent
35 #if defined(__OpenBSD__) || defined(__NetBSD__)
36 pexec=$(LC_TIME=C ps -p $PPID | awk 'NR==2 {print $5}')
38 pexec=$(LC_TIME=C /bin/ps -p $PPID 2>/dev/null | awk 'NR==2 {print $4}')
39 #elif defined(__FreeBSD__)
40 pexec=$(LC_TIME=C /bin/ps -o comm= -p $PPID 2>/dev/null)
42 pexec=$(LC_TIME=C /usr/bin/ps -p $PPID | awk 'NR==2 {print $4}')
44 Log "Xsession started by $pexec"
47 XCOMM ##########################################################################
49 XCOMM Append desktop font aliases to font path
51 XCOMM ##########################################################################
55 HASH Combine lines together to make arguments for the xset command
58 /^[ ]*$/ { fp=" +fp " ; continue }
59 { printf("%s%s", fp, $0) ; fp="," } ' $1`
62 Log "setting auxiliary font path..."
70 if [ "${pexec##*/}" != "dtlogin" ]; then
72 HASH If Xsession launched by dtlogin, it is assumed that the desktop
73 HASH font path has already been added by Xsetup, so no need to add it here.
78 if [ -r $OPENWINHOME/lib/locale/${LANG-C}/OWfontpath ]; then
79 ADDFONTPATH $OPENWINHOME/lib/locale/${LANG-C}/OWfontpath
83 HASH Switch Sun's Alt and Meta mod mappings to work with Motif
85 if $XDIR/xmodmap | /bin/grep mod4 | /bin/grep Alt > /dev/null 2>/dev/null
87 $XDIR/xmodmap -e "clear Mod1" \
89 -e "add Mod1 = Alt_L" \
90 -e "add Mod1 = Alt_R" \
91 -e "add Mod4 = Meta_L" \
92 -e "add Mod4 = Meta_R"
97 HASH Append desktop font paths. Note: these directories should be
98 HASH accessable by the X server. The file precedence is:
100 HASH CDE_CONFIGURATION_TOP/config/xfonts/$LANG
101 HASH CDE_INSTALLATION_TOP/config/xfonts/$LANG
102 HASH CDE_CONFIGURATION_TOP/config/xfonts/C
103 HASH CDE_INSTALLATION_TOP/config/xfonts/C
106 Log "setting font path..."
109 if [ "$DTXSERVERLOCATION" != "remote" -a -z "$XSTATION" ]; then
111 if [ "$DTXSERVERLOCATION" != "remote" ]; then
114 HASH Since X server is local, optimize by checking local desktop
115 HASH font directories and making one call to xset.
118 if [ "${LANG-C}" != "C" ]; then
119 if [ -f CDE_CONFIGURATION_TOP/config/xfonts/$LANG/fonts.dir ]; then
120 fontpath=CDE_CONFIGURATION_TOP/config/xfonts/$LANG
123 if [ -f CDE_INSTALLATION_TOP/config/xfonts/$LANG/fonts.dir ]; then
124 if [ -z "$fontpath" ]; then
125 fontpath=CDE_INSTALLATION_TOP/config/xfonts/$LANG
127 fontpath=$fontpath,CDE_INSTALLATION_TOP/config/xfonts/$LANG
132 if [ -f CDE_CONFIGURATION_TOP/config/xfonts/C/fonts.dir ]; then
133 if [ -z "$fontpath" ]; then
134 fontpath=CDE_CONFIGURATION_TOP/config/xfonts/C
136 fontpath=$fontpath,CDE_CONFIGURATION_TOP/config/xfonts/C
140 if [ -f CDE_INSTALLATION_TOP/config/xfonts/C/fonts.dir ]; then
141 if [ -z "$fontpath" ]; then
142 fontpath=CDE_INSTALLATION_TOP/config/xfonts/C
144 fontpath=$fontpath,CDE_INSTALLATION_TOP/config/xfonts/C
149 if [ ! -z "$fontpath" ]; then
150 $XDIR/xset fp+ $fontpath
155 HASH Since X server not local, we don't know if the desktop font
156 HASH directories exist on the X server machine, so we have to
157 HASH set them one at a time.
160 if [ "${LANG-C}" != "C" ]; then
161 $XDIR/xset fp+ CDE_CONFIGURATION_TOP/config/xfonts/$LANG 1>/dev/null
163 $XDIR/xset fp+ CDE_INSTALLATION_TOP/config/xfonts/$LANG 1>/dev/null
166 $XDIR/xset fp+ CDE_CONFIGURATION_TOP/config/xfonts/C 1>/dev/null
168 $XDIR/xset fp+ CDE_INSTALLATION_TOP/config/xfonts/C 1>/dev/null
176 XCOMM ##########################################################################
178 XCOMM Setup keyboard mapping for local display if required
180 XCOMM ##########################################################################
184 * The keyboard mapping method depends upon how the session is started:
186 * - from dtlogin with a local X server
188 * This is generally the case for the console. Since the keyboard is
189 * on the login server, the keyboard mapping will be done in Xsetup
190 * and the language will be determined via querybkd.
192 * - from dtlogin with a remote X server
194 * The is generally the case for X stations. Since the keyboard is not
195 * on the login server, we cannot query for the language. The keyboard
196 * language will thus be provided in the KBD_MAP table setup by the
197 * sysadmin and the keyboard mapping will be done in Xsetup.
199 * - using 'xinit /usr/dt/bin/Xsession' from an HFT/LFT
201 * Since the keyboard is local, the keyboard mapping will be done in
202 * Xsession and the language will be determined via querykbd.
204 * - starting Xsession from an x_st_mgr provided aixterm on an X station
206 * The X station manager sets up the keyboard mapping in this case, so
207 * no work is required.
213 HASH $1 = language name
216 # define cpp_KBDALTFILE "$KBD_LIST $XMODDIR/${1}@alt/keyboard"
218 # define cpp_KBDALTFILE "$KBD_LIST $XMODDIR/$1/keyboard.alt"
222 KBD_LIST="$KBD_LIST $IMKEYMAPPATH/$1/keyboard"
223 if [ "$IMKEYMAPPATH" = "/usr/lib/nls/im.alt" ]; then
224 KBD_LIST=cpp_KBDALTFILE
226 KBD_LIST="$KBD_LIST $XMODDIR/$1/keyboard"
228 for i in $KBD_LIST; do
231 Log "starting xmodmap $i"
242 if [ "${pexec##*/}" != "dtlogin" -a -z "$XSTATION" ]; then
244 HASH If Xsession started by dtlogin, it is assumed that the keyboard mapping
245 HASH was set up in Xsetup. If Xsession not started by dtlogin, but XSTATION
246 HASH set, it is assumed that the keyboard mapping was set up by x_st_mgr.
251 # define cpp_CNAME "C"
253 # define cpp_CNAME "C.hft"
258 HASH Determine keyboard language
261 if [ "$DTXSERVERLOCATION" = "local" ]; then
263 HASH Local display so query for keyboard map
265 KBD_LANG=`/usr/lpp/X11/bin/querykbd`
268 HASH Non-local display so use KEY_MAP list
272 [ -z "${KBD_MAP[i]}" ] && break
273 if [ "$DISPLAY" = "${KBD_MAP[i]%% *}" ]; then
274 KBD_LANG=${KBD_MAP[i]##* }
282 KBD_LANG=`/usr/lpp/X11/bin/querykbd`
286 HASH Set up keyboard mapping
289 XMODDIR=/usr/lpp/X11/defaults/xmodmap
291 if [ ! -z "$KBD_LANG" ]; then
292 if [ "$KBD_LANG" != "NULL" -a "$KBD_LANG" != cpp_CNAME ]; then
293 SetKeyboardMap $KBD_LANG
309 if [ "$DTXSERVERLOCATION" != "remote" ]; then
311 FONTLIB=/usr/share/fonts/X11
312 for i in misc 75dpi 100dpi Speedo Type1 PJE
314 if [ -f $FONTLIB/$i/fonts.dir ]; then
315 if [ ! -z "$fontpath" ]; then
316 fontpath=$fontpath,$FONTLIB/$i/
318 fontpath=$FONTLIB/$i/
323 if [ ! -z "$fontpath" ]; then
324 $XDIR/xset fp+ $fontpath
330 #if defined(CSRG_BASED)
332 if [ "$DTXSERVERLOCATION" != "remote" ]; then
334 #if defined(__FreeBSD__)
335 FONTLIB=/usr/local/lib/X11/fonts
336 #elif defined(__OpenBSD__)
337 FONTLIB=/usr/X11R6/lib/X11/fonts
338 #elif defined(__NetBSD__)
339 FONTLIB=/usr/X11R7/lib/X11/fonts
341 for i in misc 75dpi 100dpi Speedo Type1 PJE
343 if [ -f $FONTLIB/$i/fonts.dir ]; then
344 if [ ! -z "$fontpath" ]; then
345 fontpath=$fontpath,$FONTLIB/$i/
347 fontpath=$FONTLIB/$i/
352 if [ ! -z "$fontpath" ]; then
353 $XDIR/xset fp+ $fontpath