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 (__osf__) || defined(__OpenBSD__) || defined(__NetBSD__)
36 pexec=$(LC_TIME=C ps -p $PPID | awk 'NR==2 {print $5}')
37 #elif defined(USL) && (OSMAJORVERSION > 1)
38 pexec=$(LC_TIME=C ps -p $PPID | awk 'NR==2 {print $6}')
40 pexec=$(LC_TIME=C /bin/ps -p $PPID 2>/dev/null | awk 'NR==2 {print $4}')
41 #elif defined(__FreeBSD__)
42 pexec=$(LC_TIME=C /bin/ps -o comm= -p $PPID 2>/dev/null)
44 pexec=$(LC_TIME=C /usr/bin/ps -p $PPID | awk 'NR==2 {print $4}')
46 Log "Xsession started by $pexec"
49 XCOMM ##########################################################################
51 XCOMM Append desktop font aliases to font path
53 XCOMM ##########################################################################
57 HASH Combine lines together to make arguments for the xset command
60 /^[ ]*$/ { fp=" +fp " ; continue }
61 { printf("%s%s", fp, $0) ; fp="," } ' $1`
64 Log "setting auxiliary font path..."
72 if [ "${pexec##*/}" != "dtlogin" ]; then
74 HASH If Xsession launched by dtlogin, it is assumed that the desktop
75 HASH font path has already been added by Xsetup, so no need to add it here.
80 if [ -r $OPENWINHOME/lib/locale/${LANG-C}/OWfontpath ]; then
81 ADDFONTPATH $OPENWINHOME/lib/locale/${LANG-C}/OWfontpath
85 HASH Switch Sun's Alt and Meta mod mappings to work with Motif
87 if $XDIR/xmodmap | /bin/grep mod4 | /bin/grep Alt > /dev/null 2>/dev/null
89 $XDIR/xmodmap -e "clear Mod1" \
91 -e "add Mod1 = Alt_L" \
92 -e "add Mod1 = Alt_R" \
93 -e "add Mod4 = Meta_L" \
94 -e "add Mod4 = Meta_R"
99 HASH Append desktop font paths. Note: these directories should be
100 HASH accessable by the X server. The file precedence is:
102 HASH CDE_CONFIGURATION_TOP/config/xfonts/$LANG
103 HASH CDE_INSTALLATION_TOP/config/xfonts/$LANG
104 HASH CDE_CONFIGURATION_TOP/config/xfonts/C
105 HASH CDE_INSTALLATION_TOP/config/xfonts/C
108 Log "setting font path..."
111 if [ "$DTXSERVERLOCATION" != "remote" -a -z "$XSTATION" ]; then
113 if [ "$DTXSERVERLOCATION" != "remote" ]; then
116 HASH Since X server is local, optimize by checking local desktop
117 HASH font directories and making one call to xset.
120 if [ "${LANG-C}" != "C" ]; then
121 if [ -f CDE_CONFIGURATION_TOP/config/xfonts/$LANG/fonts.dir ]; then
122 fontpath=CDE_CONFIGURATION_TOP/config/xfonts/$LANG
125 if [ -f CDE_INSTALLATION_TOP/config/xfonts/$LANG/fonts.dir ]; then
126 if [ -z "$fontpath" ]; then
127 fontpath=CDE_INSTALLATION_TOP/config/xfonts/$LANG
129 fontpath=$fontpath,CDE_INSTALLATION_TOP/config/xfonts/$LANG
134 if [ -f CDE_CONFIGURATION_TOP/config/xfonts/C/fonts.dir ]; then
135 if [ -z "$fontpath" ]; then
136 fontpath=CDE_CONFIGURATION_TOP/config/xfonts/C
138 fontpath=$fontpath,CDE_CONFIGURATION_TOP/config/xfonts/C
142 if [ -f CDE_INSTALLATION_TOP/config/xfonts/C/fonts.dir ]; then
143 if [ -z "$fontpath" ]; then
144 fontpath=CDE_INSTALLATION_TOP/config/xfonts/C
146 fontpath=$fontpath,CDE_INSTALLATION_TOP/config/xfonts/C
151 if [ ! -z "$fontpath" ]; then
152 $XDIR/xset fp+ $fontpath
157 HASH Since X server not local, we don't know if the desktop font
158 HASH directories exist on the X server machine, so we have to
159 HASH set them one at a time.
162 if [ "${LANG-C}" != "C" ]; then
163 $XDIR/xset fp+ CDE_CONFIGURATION_TOP/config/xfonts/$LANG 1>/dev/null
165 $XDIR/xset fp+ CDE_INSTALLATION_TOP/config/xfonts/$LANG 1>/dev/null
168 $XDIR/xset fp+ CDE_CONFIGURATION_TOP/config/xfonts/C 1>/dev/null
170 $XDIR/xset fp+ CDE_INSTALLATION_TOP/config/xfonts/C 1>/dev/null
178 #if defined (__osf__)
181 if [ "$DTXSERVERLOCATION" != "remote" ]; then
183 HASH We can only modify the font path or the keymap if the X server is
186 HASH Since X server is local, optimize by checking local desktop
187 HASH font directories and making one call to xset.
191 HASH check if the system has a Low or High Resolution Monitor
192 HASH - High Resolution (1280 x 1024) uses 100 dpi fonts.
193 HASH - Medium Resolution (1024 x 864 ) uses 75 dpi fonts.
194 HASH - Low Resolution (1024 x 768 or lower) uses 75 dpi fonts.
195 HASH This will only switch to 75dpi fonts if there is a low or medium
196 HASH resolution monitor found.
203 FONTLIB="/usr/lib/X11/fonts"
204 I18N="/usr/i18n/lib/X11/fonts/decwin"
205 pixwidth=`/usr/sbin/sizer -gr | awk -Fx ' { print $1 } ' `
206 if [ ${pixwidth} -lt 1280 ]
216 HASH Add scalable fonts to the font path, based on
217 HASH screen resolution
219 if [ ${pixwidth} -lt 1024 ]
222 HASH Prepend fontpaths
224 prefplist="${FONTLIB}/Speedo ${FONTLIB}/Type1 ${FONTLIB}/Type1Adobe"
227 HASH Append fontpaths
229 appfplist="${FONTLIB}/Type1Adobe"
233 HASH Append fontpaths
234 HASH add optional extra fonts
236 cde_configuration_top=CDE_CONFIGURATION_TOP
237 cde_installation_top=CDE_INSTALLATION_TOP
238 appfplist="${appfplist} ${FONTLIB}/user/${nat_res} ${FONTLIB}/user/misc"
239 if [ "${LANG-C}" != "C" ]; then
240 appfplist="${appfplist} $cde_configuration_top/config/xfonts/$LANG/$nat_res"
241 appfplist="${appfplist} $cde_configuration_top/config/xfonts/$LANG/$alt_res"
243 appfplist="${appfplist} $cde_configuration_top/config/xfonts/C"
244 appfplist="${appfplist} $cde_configuration_top/config/xfonts/C/$nat_res"
245 appfplist="${appfplist} $cde_configuration_top/config/xfonts/C/$alt_res"
246 if [ "${LANG-C}" != "C" ]; then
247 appfplist="${appfplist} $cde_installation_top/config/xfonts/$LANG/$nat_res"
248 appfplist="${appfplist} $cde_installation_top/config/xfonts/$LANG/$alt_res"
250 appfplist="${appfplist} $cde_installation_top/config/xfonts/C"
251 appfplist="${appfplist} $cde_installation_top/config/xfonts/C/$nat_res"
252 appfplist="${appfplist} $cde_installation_top/config/xfonts/C/$alt_res"
255 HASH Prepend fontpaths
256 HASH add i18n fonts if they exist
258 prefplist="${I18N}/${nat_res} ${I18N}/${alt_res} ${prefplist}"
261 HASH Prepend to fontpath
263 for i in ${prefplist}
265 if [ -f ${i}/fonts.dir ]
277 if [ ${setfont} = Yes ]
283 HASH set the old slow way.....
285 for i in ${prefplist}
287 if [ -f ${i}/fonts.dir ]
294 HASH End of the setting the old slow way.........
301 HASH Append to fontpath
303 for i in ${appfplist}
305 if [ -f ${i}/fonts.dir ]
317 if [ ${setfont} = Yes ]
323 HASH set the old slow way.....
325 for i in ${appfplist}
327 if [ -f ${i}/fonts.dir ]
334 HASH End of the setting the old slow way.........
344 XCOMM ##########################################################################
346 XCOMM Setup keyboard mapping for local display if required
348 XCOMM ##########################################################################
352 * The keyboard mapping method depends upon how the session is started:
354 * - from dtlogin with a local X server
356 * This is generally the case for the console. Since the keyboard is
357 * on the login server, the keyboard mapping will be done in Xsetup
358 * and the language will be determined via querybkd.
360 * - from dtlogin with a remote X server
362 * The is generally the case for X stations. Since the keyboard is not
363 * on the login server, we cannot query for the language. The keyboard
364 * language will thus be provided in the KBD_MAP table setup by the
365 * sysadmin and the keyboard mapping will be done in Xsetup.
367 * - using 'xinit /usr/dt/bin/Xsession' from an HFT/LFT
369 * Since the keyboard is local, the keyboard mapping will be done in
370 * Xsession and the language will be determined via querykbd.
372 * - starting Xsession from an x_st_mgr provided aixterm on an X station
374 * The X station manager sets up the keyboard mapping in this case, so
375 * no work is required.
381 HASH $1 = language name
384 # define cpp_KBDALTFILE "$KBD_LIST $XMODDIR/${1}@alt/keyboard"
386 # define cpp_KBDALTFILE "$KBD_LIST $XMODDIR/$1/keyboard.alt"
390 KBD_LIST="$KBD_LIST $IMKEYMAPPATH/$1/keyboard"
391 if [ "$IMKEYMAPPATH" = "/usr/lib/nls/im.alt" ]; then
392 KBD_LIST=cpp_KBDALTFILE
394 KBD_LIST="$KBD_LIST $XMODDIR/$1/keyboard"
396 for i in $KBD_LIST; do
399 Log "starting xmodmap $i"
410 if [ "${pexec##*/}" != "dtlogin" -a -z "$XSTATION" ]; then
412 HASH If Xsession started by dtlogin, it is assumed that the keyboard mapping
413 HASH was set up in Xsetup. If Xsession not started by dtlogin, but XSTATION
414 HASH set, it is assumed that the keyboard mapping was set up by x_st_mgr.
419 # define cpp_CNAME "C"
421 # define cpp_CNAME "C.hft"
426 HASH Determine keyboard language
429 if [ "$DTXSERVERLOCATION" = "local" ]; then
431 HASH Local display so query for keyboard map
433 KBD_LANG=`/usr/lpp/X11/bin/querykbd`
436 HASH Non-local display so use KEY_MAP list
440 [ -z "${KBD_MAP[i]}" ] && break
441 if [ "$DISPLAY" = "${KBD_MAP[i]%% *}" ]; then
442 KBD_LANG=${KBD_MAP[i]##* }
450 KBD_LANG=`/usr/lpp/X11/bin/querykbd`
454 HASH Set up keyboard mapping
457 XMODDIR=/usr/lpp/X11/defaults/xmodmap
459 if [ ! -z "$KBD_LANG" ]; then
460 if [ "$KBD_LANG" != "NULL" -a "$KBD_LANG" != cpp_CNAME ]; then
461 SetKeyboardMap $KBD_LANG
477 if [ "$DTXSERVERLOCATION" != "remote" ]; then
479 FONTLIB=/usr/share/fonts/X11
480 for i in misc 75dpi 100dpi Speedo Type1 PJE
482 if [ -f $FONTLIB/$i/fonts.dir ]; then
483 if [ ! -z "$fontpath" ]; then
484 fontpath=$fontpath,$FONTLIB/$i/
486 fontpath=$FONTLIB/$i/
491 if [ ! -z "$fontpath" ]; then
492 $XDIR/xset fp+ $fontpath
498 #if defined(CSRG_BASED)
500 if [ "$DTXSERVERLOCATION" != "remote" ]; then
502 #if defined(__FreeBSD__)
503 FONTLIB=/usr/local/lib/X11/fonts
504 #elif defined(__OpenBSD__)
505 FONTLIB=/usr/X11R6/lib/X11/fonts
506 #elif defined(__NetBSD__)
507 FONTLIB=/usr/X11R7/lib/X11/fonts
509 for i in misc 75dpi 100dpi Speedo Type1 PJE
511 if [ -f $FONTLIB/$i/fonts.dir ]; then
512 if [ ! -z "$fontpath" ]; then
513 fontpath=$fontpath,$FONTLIB/$i/
515 fontpath=$FONTLIB/$i/
520 if [ ! -z "$fontpath" ]; then
521 $XDIR/xset fp+ $fontpath