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
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}')
39 #elif defined(linux) || defined(CSRG_BASED)
40 pexec=$(LC_TIME=C /bin/ps -p $PPID 2>/dev/null | awk 'NR==2 {print $4}')
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 #if defined (__osf__)
179 if [ "$DTXSERVERLOCATION" != "remote" ]; then
181 HASH We can only modify the font path or the keymap if the X server is
184 HASH Since X server is local, optimize by checking local desktop
185 HASH font directories and making one call to xset.
189 HASH check if the system has a Low or High Resolution Monitor
190 HASH - High Resolution (1280 x 1024) uses 100 dpi fonts.
191 HASH - Medium Resolution (1024 x 864 ) uses 75 dpi fonts.
192 HASH - Low Resolution (1024 x 768 or lower) uses 75 dpi fonts.
193 HASH This will only switch to 75dpi fonts if there is a low or medium
194 HASH resolution monitor found.
201 FONTLIB="/usr/lib/X11/fonts"
202 I18N="/usr/i18n/lib/X11/fonts/decwin"
203 pixwidth=`/usr/sbin/sizer -gr | awk -Fx ' { print $1 } ' `
204 if [ ${pixwidth} -lt 1280 ]
214 HASH Add scalable fonts to the font path, based on
215 HASH screen resolution
217 if [ ${pixwidth} -lt 1024 ]
220 HASH Prepend fontpaths
222 prefplist="${FONTLIB}/Speedo ${FONTLIB}/Type1 ${FONTLIB}/Type1Adobe"
225 HASH Append fontpaths
227 appfplist="${FONTLIB}/Type1Adobe"
231 HASH Append fontpaths
232 HASH add optional extra fonts
234 cde_configuration_top=CDE_CONFIGURATION_TOP
235 cde_installation_top=CDE_INSTALLATION_TOP
236 appfplist="${appfplist} ${FONTLIB}/user/${nat_res} ${FONTLIB}/user/misc"
237 if [ "${LANG-C}" != "C" ]; then
238 appfplist="${appfplist} $cde_configuration_top/config/xfonts/$LANG/$nat_res"
239 appfplist="${appfplist} $cde_configuration_top/config/xfonts/$LANG/$alt_res"
241 appfplist="${appfplist} $cde_configuration_top/config/xfonts/C"
242 appfplist="${appfplist} $cde_configuration_top/config/xfonts/C/$nat_res"
243 appfplist="${appfplist} $cde_configuration_top/config/xfonts/C/$alt_res"
244 if [ "${LANG-C}" != "C" ]; then
245 appfplist="${appfplist} $cde_installation_top/config/xfonts/$LANG/$nat_res"
246 appfplist="${appfplist} $cde_installation_top/config/xfonts/$LANG/$alt_res"
248 appfplist="${appfplist} $cde_installation_top/config/xfonts/C"
249 appfplist="${appfplist} $cde_installation_top/config/xfonts/C/$nat_res"
250 appfplist="${appfplist} $cde_installation_top/config/xfonts/C/$alt_res"
253 HASH Prepend fontpaths
254 HASH add i18n fonts if they exist
256 prefplist="${I18N}/${nat_res} ${I18N}/${alt_res} ${prefplist}"
259 HASH Prepend to fontpath
261 for i in ${prefplist}
263 if [ -f ${i}/fonts.dir ]
275 if [ ${setfont} = Yes ]
281 HASH set the old slow way.....
283 for i in ${prefplist}
285 if [ -f ${i}/fonts.dir ]
292 HASH End of the setting the old slow way.........
299 HASH Append to fontpath
301 for i in ${appfplist}
303 if [ -f ${i}/fonts.dir ]
315 if [ ${setfont} = Yes ]
321 HASH set the old slow way.....
323 for i in ${appfplist}
325 if [ -f ${i}/fonts.dir ]
332 HASH End of the setting the old slow way.........
342 XCOMM ##########################################################################
344 XCOMM Setup keyboard mapping for local display if required
346 XCOMM ##########################################################################
350 * The keyboard mapping method depends upon how the session is started:
352 * - from dtlogin with a local X server
354 * This is generally the case for the console. Since the keyboard is
355 * on the login server, the keyboard mapping will be done in Xsetup
356 * and the language will be determined via querybkd.
358 * - from dtlogin with a remote X server
360 * The is generally the case for X stations. Since the keyboard is not
361 * on the login server, we cannot query for the language. The keyboard
362 * language will thus be provided in the KBD_MAP table setup by the
363 * sysadmin and the keyboard mapping will be done in Xsetup.
365 * - using 'xinit /usr/dt/bin/Xsession' from an HFT/LFT
367 * Since the keyboard is local, the keyboard mapping will be done in
368 * Xsession and the language will be determined via querykbd.
370 * - starting Xsession from an x_st_mgr provided aixterm on an X station
372 * The X station manager sets up the keyboard mapping in this case, so
373 * no work is required.
379 HASH $1 = language name
382 # define cpp_KBDALTFILE "$KBD_LIST $XMODDIR/${1}@alt/keyboard"
384 # define cpp_KBDALTFILE "$KBD_LIST $XMODDIR/$1/keyboard.alt"
388 KBD_LIST="$KBD_LIST $IMKEYMAPPATH/$1/keyboard"
389 if [ "$IMKEYMAPPATH" = "/usr/lib/nls/im.alt" ]; then
390 KBD_LIST=cpp_KBDALTFILE
392 KBD_LIST="$KBD_LIST $XMODDIR/$1/keyboard"
394 for i in $KBD_LIST; do
397 Log "starting xmodmap $i"
408 if [ "${pexec##*/}" != "dtlogin" -a -z "$XSTATION" ]; then
410 HASH If Xsession started by dtlogin, it is assumed that the keyboard mapping
411 HASH was set up in Xsetup. If Xsession not started by dtlogin, but XSTATION
412 HASH set, it is assumed that the keyboard mapping was set up by x_st_mgr.
417 # define cpp_CNAME "C"
419 # define cpp_CNAME "C.hft"
424 HASH Determine keyboard language
427 if [ "$DTXSERVERLOCATION" = "local" ]; then
429 HASH Local display so query for keyboard map
431 KBD_LANG=`/usr/lpp/X11/bin/querykbd`
434 HASH Non-local display so use KEY_MAP list
438 [ -z "${KBD_MAP[i]}" ] && break
439 if [ "$DISPLAY" = "${KBD_MAP[i]%% *}" ]; then
440 KBD_LANG=${KBD_MAP[i]##* }
448 KBD_LANG=`/usr/lpp/X11/bin/querykbd`
452 HASH Set up keyboard mapping
455 XMODDIR=/usr/lpp/X11/defaults/xmodmap
457 if [ ! -z "$KBD_LANG" ]; then
458 if [ "$KBD_LANG" != "NULL" -a "$KBD_LANG" != cpp_CNAME ]; then
459 SetKeyboardMap $KBD_LANG
473 #if defined(CSRG_BASED) || defined(linux)
475 if [ "$DTXSERVERLOCATION" != "remote" ]; then
477 FONTLIB=/usr/share/fonts/X11
478 for i in misc 75dpi 100dpi Speedo Type1 PJE
480 if [ -f $FONTLIB/$i/fonts.dir ]; then
481 if [ ! -z "$fontpath" ]; then
482 fontpath=$fontpath,$FONTLIB/$i/
484 fontpath=$FONTLIB/$i/
489 if [ ! -z "$fontpath" ]; then
490 $XDIR/xset fp+ $fontpath