-
Notifications
You must be signed in to change notification settings - Fork 1
/
.xinitrc
1455 lines (1357 loc) · 55.3 KB
/
.xinitrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#! /bin/sh
:
#
# .xinitrc - X Window System startup file (also .xsession)
#
#ident "@(#)HOME:.xinitrc 37.34 24/11/29 12:35:59 (woods)"
# N.B.: see below for the best place to enable 'set -x' for debugging...
# XXX WARNING XXX: It seems something on macos (launchd_startx?) blows up if
# any line of output from this script is more than 512 bytes!!! Pipe long lines
# through: | sed 's/:/: /g' | fold -s
# To test you might be able to use Xnest:
#
# ( cd; XNESTDISPLAY=$DISPLAY startx -- $X11PATH/bin/Xnest; cd - )
#
# ( cd; WM="$HOME/bin/ctwm -v -k -K $HOME/.ctwmrc.m4out-Xnest" XNESTDISPLAY=$display xinit -- $X11PATH/bin/Xnest; cd - )
#
# Note for all the fonts you use you need them on both the host running Xnest
# and the host running the native Xserver, which of course should not be a
# problem if they are one in the same.
# Assumptions that may cause breakage:
#
# - the shell supports functions
# - the shell supports $(cmd) substitution
# - other assumptions made by ~/.profile
#
# ./.profile should provide proper path setup
#
# ./.shrc should provide a function "onx11server"
# argv0 must be set before sourcing .profile, else we'll loop!
#
argv0="$(basename $0)"
echo "$argv0: running from $0 (shell flags: -$-) on '$(tty)'"
XOPATH=$PATH
echo "$argv0: initial PATH='$PATH'" | sed 's/:/: /g' | fold -s
XODISPLAY=$DISPLAY
echo "$argv0: starting up with DISPLAY='$DISPLAY'"
#echo "With the following arguments:"
#
#c=0
#for i in "${@}"; do
# c=$(expr ${c} + 1)
# echo "arg #${c}: \"${i}\""
#done
#if [ $c -eq 0 ]; then
# echo "# (No arguments)"
#fi
#echo '# End-of-Arguments'
ONCONSOLE=false
export ONCONSOLE
if [ $(uname -s) != "Darwin" -a -w /dev/console ]; then
ONCONSOLE=true
echo "$argv0: redirecting stdout and stderr to /dev/console."
exec 1>/dev/console 2>&1
echo "$argv0: redirected stdout and stderr to /dev/console"
elif [ "$argv0" = ".xinitrc" ]; then
if [ -t 0 ]; then
echo "$argv0: redirecting stdout and stderr to ~/.xinit-errors."
exec >$HOME/.xinit-errors 2>&1
echo "$argv0: redirected stdout and stderr to ~/.xinit-errors"
fi
elif [ "$argv0" = ".xsession" ]; then
# started as ~/.xsession by Xdm...
#
# output should already be going to ~/.xsession-errors (or /dev/console)?
echo "$argv0: stdout and stderr should be going to ~/.xsession-errors"
:
fi
# N.B.: we assume $DISPLAY is set correctly enough that clients run from this
# script can connect and use it.
# note we redirect input from /dev/null while sourcing in hopes of
# showing these scripts that they are not attached to a TTY.
#
# XXX N.B.: startx/xinit inherit the environment from the shell that starts
# them! Maybe we should try clearing the environment first? (exec env -i;
# keeping just what is essential, plus a magic guard...)
#
if [ -r /etc/profile ]; then
echo "$argv0: sourcing /etc/profile"
. /etc/profile < /dev/null
else
echo "$argv0: no /etc/profile on this host!"
fi
# XXX /etc/shrc ??? or should ~/.profile or ~/.shrc do that?
if [ -r $HOME/.profile ]; then
echo "$argv0: sourcing $HOME/.profile"
. $HOME/.profile < /dev/null
else
echo "$argv0: no $HOME/.profile on this host!"
fi
# XXX I should think harder about just how much of the environment I really do
# want all subsequent X11 applications to inherit, especially, maybe, the window
# manager. For example some things that can be over-ridden in ~/.localprofile
# will not be reset by ~/.profile if they're exported via the environment here.
if [ "$XOPATH" != "$PATH" ]; then
echo "$argv0: adjusted PATH='$PATH'" | sed 's/:/: /g' | fold -s
fi
unset XOPATH
echo "$argv0: using X11 in '$X11PATH'"
# XXX for debugging
#
# N.B.: debugging can break XQuartz as mentioned in the warning above!
#
DEBUG=false
#DEBUG=true
if $DEBUG; then
echo "$argv0: Debugging enabled ...."
set -x
fi
# try making sure we are using the maximum display resolution right away
#
# N.B.: This assumes we've told startx to set the DPI parameter correctly for
# the current screen. On macos, with XQuartz, for the Retina 6K XDR Pro Display
# XDR, which has approximately 218 DPI, this is done with:
#
# defaults write org.xquartz.X11 dpi -int 218
#
# NOTE: MacBook Air 13-inch Retina is 227 dpi (2880 x 1800)
#
# On XQuartz/Darwin (and in general with the Xorg Xserver) the command-line
# "-dpi" value is used to compute the frame buffer's width and height based on
# the number of pixels each way, but there's no way to fetch this original
# command-line parameter back; except in the way xdpyinfo does, i.e. by getting
# the pixel dimensions and the screen dimensions and re-computing the x/y DPI.
# Due to rounding errors this may end up returning an off-by-one value for one
# of the dimentions.
#
# Note that when in XQuartz is in full-screen mode you can get back to the macos
# desktop with the "toggle full screen" keyboard shortcut (which is normally
# <command><option><a>). Then if you want to get back into X11 full-screen mode
# again you can re-run the "xrandr -s" command again. An easy way to do this is
# to use the Shortcuts application to create a shortcut that can also be hooked
# to the same key sequence (in the "Run with:" field in the shortcut editor
# "Details" sub-panel) as this key sequence is almost never used in any other
# macos app (that I use, anyway) [it doesn't work quite right from Mail though].
#
# Here's the script for the shortcut:
#
#
# #!/bin/ksh
# #
# # XXX This gets terribly confused if there is more than one
# # ~/.serverauth.* file, obviously....
# #
# if [ -r $HOME/.serverauth.* ]; then
# DISPLAY=$(launchctl getenv DISPLAY)
# MAXRES=$(xrandr -display $DISPLAY -q 2>/dev/null | awk '/^Screen [0-9]+:/ {print $(NF-2) "x" $(NF)}')
# echo "Switch-To-X11: switching $DISPLAY to '$MAXRES'" 1>&2
# xrandr -display $DISPLAY -s "$MAXRES"
# else
# osascript -e 'display alert "Switch-To-X11" message "Just hit the X icon in the dock!"' > /dev/null
# fi
#
#
echo "$argv0: Getting ready to try xrandr stuff ...."
if type xrandr >/dev/null 2>&1; then
xrandr -s $(xrandr 2>/dev/null | awk '/^Screen [0-9]+:/ {print $(NF-2) "x" $(NF)}')
echo "$argv0: Done xrandr ...."
else
echo "$argv0: cannot force hi-res display without xrandr utility..."
fi
# Modern X11, since Release 5, has had decent i18n support
#
# This is primarily done here to make sure LC_CTYPE propagates through the
# window manager.
#
# Note these settings should match what ~/.profile will set for a uxterm(1)....
#
if $HAVELOCALE; then
if locale -a | fgrep -i en_CA.UTF-8 >/dev/null; then
if [ -z "${LC_CTYPE}" ]; then
LC_CTYPE="en_CA.UTF-8"
export LC_CTYPE
fi
LC_NUMERIC="en_CA.UTF-8"
export LC_NUMERIC
LC_MONETARY="en_CA.UTF-8"
export LC_MONETARY
else
echo "$argv0: WARNING!!! It seems 'locale -a' does not report having en_CA.UTF-8!"
fi
else
echo "$argv0: WARNING!!! An X11 system without locale(1) is unheard of!"
fi
# Xrdb stuff, especially when using M4, must come before any other client is
# started!
#
if $DEBUG; then
# look at the default resources
xrdb -query -all
fi
#
# First load any available default X11 resource database
#
if [ -r "/usr/lib/X11/Xdefaults" ]; then
xrdb -merge /usr/lib/X11/Xdefaults
elif [ -r "$X11PATH/lib/X11/Xdefaults" ]; then
xrdb -merge $X11PATH/lib/X11/Xdefaults
elif [ -r "$OPENWINHOME/lib/Xdefaults" ]; then
xrdb -merge $OPENWINHOME/lib/Xdefaults
fi
if [ -r $HOME/.Xdefaults ]; then
# n.b.: note the custom use of m4!
xrdb -cpp m4 -merge $HOME/.Xdefaults # Load user's X11 resource database
fi
# Find the X11 Core Fonts
#
if [ -r ${X11PATH}/lib/X11/fonts/misc/fonts.dir ]; then
X11FONTDIR=${X11PATH}/lib/X11/fonts
elif [ -r ${X11PATH}/share/fonts/X11/misc/fonts.dir ]; then
X11FONTDIR=${X11PATH}/share/fonts/X11
else
X11FONTDIR=${X11PATH}/share/fonts
fi
export X11FONTDIR
echo "$argv0: X11FONTDIR='${X11FONTDIR}'"
# Set shell variables from things calculated in ~/.X11-macros.m4
#
# n.b.: note the abuse of xrdb and the custom use of m4!
#
# XXX xdpyinfo provides the DPI values we need without need for calculations
# that might suffer rounding, but without going metric getting $SCREENSIZE* from
# either xdpyinfo or xrdb's m4 defines is a rough calculation. The latter only
# provides [XY]_RESOLUTION values in pixels per metre for some stupid reason!
#
# However everywhere else, i.e. namely in .X11-m4macros.m4 (and .ctwmrc), we
# have to use those defines and the rough calculations they require, so we'll
# use xrdb here to make sure everything matches.
#
# XXX there are some ugly translations between M4 names and variable names that
# should probably all be normalised!
#
eval $(
{
echo "changequote([, ])"
cat .X11-m4macros.m4
echo "[VENDORSTR]='VENDOR'[; export VENDORSTR]"
echo "[SCREENDEPTH]=PLANES[; export SCREENDEPTH]"
echo "[SCREENSIZE]=WIDTH[x]HEIGHT[; export SCREENSIZE]"
echo "[SCREENSIZE_X]=WIDTH[; export SCREENSIZE_X]"
echo "[SCREENSIZE_Y]=HEIGHT[; export SCREENSIZE_Y]"
echo "[SCREENDIM]='ScreenDimX[x]ScreenDimY'[; export SCREENDIM]"
echo "[SCREENDIM_X]=ScreenDimX[; export SCREENDIM_X]"
echo "[SCREENDIM_Y]=ScreenDimY[; export SCREENDIM_Y]"
echo "[SCREENDPI_X]=HorizDPI[; export SCREENDPI_X]"
echo "[SCREENDPI_Y]=VertDPI[; export SCREENDPI_Y]"
echo "[FontXDPI]=FontXDPI[; export FontXDPI]"
echo "[FontYDPI]=FontYDPI[; export FontYDPI]"
echo "[BorderWidth]=BORDERWIDTH[; export BorderWidth]"
echo "[TDBorderWidth]=TDBORDERWIDTH[; export TDBorderWidth]"
echo "[TitleHeight]=TitleHeight[; export TitleHeight]"
echo "[ClockSize]=ClockSize[; export ClockSize]"
echo "[ClockWidth]=ClockWidth[; export ClockWidth]"
echo "[ClockHeight]=ClockHeight[; export ClockHeight]"
echo "[ClockOffH]=ClockOffH[; export ClockOffH]"
echo "[ClockOffV]=ClockOffV[; export ClockOffV]"
echo "[ClockGeom]='ClockGeom'[; export ClockGeom]"
echo "[DClockHeight]=DClockHeight[; export DClockHeight]"
echo "[DClockGeom]='DClockGeom'[; export DClockGeom]"
echo "[DecentFont]='DecentFont'[; export DecentFont]"
echo "[DecentFontSlant]='DecentFontSlant'[; export DecentFontSlant]"
echo "[DecentFontSpc]='DecentFontSpc'[; export DecentFontSpc]"
echo "[DecentFontSans]='DecentFontSans'[; export DecentFontSans]"
echo "[DecentFontSansSlant]='DecentFontSansSlant'[; export DecentFontSansSlant]"
echo "[DecentFontSansSpc]='DecentFontSansSpc'[; export DecentFontSansSpc]"
echo "[DecentFontSerif]='DecentFontSerif'[; export DecentFontSerif]"
echo "[DecentFontSerifSlant]='DecentFontSerifSlant'[; export DecentFontSerifSlant]"
echo "[DecentFontSerifSpc]='DecentFontSerifSpc'[; export DecentFontSerifSpc]"
echo "[HugeDeciPt]=HugeDeciPt[; export HugeDeciPt]"
echo "[HugePt]=HugePt[; export HugePt]"
echo "[BiggerDeciPt]=BiggerDeciPt[; export BiggerDeciPt]"
echo "[BiggerPt]=BiggerPt[; export BiggerPt]"
echo "[DecentDeciPt]=DecentDeciPt[; export DecentDeciPt]"
echo "[DecentPt]=DecentPt[; export DecentPt]"
echo "[SmallerDeciPt]=SmallerDeciPt[; export SmallerDeciPt]"
echo "[SmallerPt]=SmallerPt[; export SmallerPt]"
echo "[TinyDeciPt]=TinyDeciPt[; export TinyDeciPt]"
echo "[TinyPt]=TinyPt[; export TinyPt]"
echo "[XloadWidth]=XloadWidth[; export XloadWidth]"
echo "[XloadHeight]=XloadHeight[; export XloadHeight]"
echo "[XloadGeom]='XloadGeom'[; export XloadGeom]"
echo "[WSWidth]=WS_WIDTH[; export WSWidth]"
echo "[WSHeight]=WS_HEIGHT[; export WSHeight]"
echo "[WSOff]=WS_OFF[; export WSOff]"
echo "[XchronoWidth]='XchronoWidth'[; export XchronoWidth]"
echo "[XchronoGeom]='XchronoGeom'[; export XchronoGeom]"
} | xrdb -quiet -cpp m4 -E -n | sed -e 1d -e '/^!/d')
# xxx these aren't used, and could-should be in .X11-m4macros.m4???
#
DefaultFontSpec='-*-${DecentFont}-medium-r-normal--0-${DecentDeciPt}-${FontXDPI}-${FontYDPI}-m-*-iso10646-1'
DefaultFontSpecL1='-*-${DecentFont}-medium-r-normal--0-${DecentDeciPt}-${FontXDPI}-${FontYDPI}-m-*-iso8859-1'
export DefaultFontSpec DefaultFontSpecL1
#
DecentFontSpec=$(eval echo "${DefaultFontSpec}")
DecentFontSpecL1=$(eval echo "${DefaultFontSpecL1}")
export DecentFontSpec DecentFontSpecL1
#
# For Xft ~/.Xdefaults forces the Xft.dpi resource to be set to what is worked
# out above so this allows the physical font size to be specified, in points,
# (either with a ":size=" attribute in the font spec (which can be abbreviated
# as "-POINTS"), or with a command-line option to override that, e.g. with
# Xterm's "-fs" option.
#
# Note for Xft using fc-list(1) is probably the best way to find Xft fonts...
#
# fc-list :scalable=true:spacing=100:lang=en: family
#
# See "Font Name" in the following for how XftPatterns are specified:
#
# https://fontconfig.pages.freedesktop.org/fontconfig/fontconfig-user.html
#
# See also fonts.conf(5).
#
# N.B.: Xft does seem able to find fonts with the spaces removed from their
# "fullname", e.g. "DejaVuSansMono" will find "DejaVu Sans Mono". Phew! (This
# seems to be due to testing with a rule: "Equal(ignore blanks)")
#
# (xxx this probably isn't necessary as it is also specified in ~/.Xdefaults
# with the wild-carded faceName resource)
#
DefaultXftFont=$(echo "${DecentFont}" | sed 's/ //g')
# note: ":size=N" can be replaced by "-N" but this form is more explicit
DecentXftFontSpec="${DefaultXftFont}:size=${DecentPt}"
export DefaultXftFont DecentXftFontSpec
# For hi-res displays one critical entry should be in ~/.fonts/fonts.alias:
#
# cursor -xfree86-cursor-medium-r-normal--0-160-218-218-p-0-adobe-fontspecific
#
# The target font comes from what is now called the Xorg "font-xfree86-type1"
# package, and consists of a single file: cursor.pfa. If you don't have it in
# your Xserver's .../fonts/Type1 directory then you may need to find a copy and
# put it in your ~/.fonts directory.
#
# (note there are "xcursor-*" pkgsrc packages with scalable loadable cursors)
#
# FontPath setup must also come before any other graphical client is started!
#
# Install any/all of the general-coverage (and symbol) TTF or OTF fonts,
# e.g. from pkgsrc, and then:
#
# cd ${PKG}/share/fonts/X11/{OTF,TTF}
# mkfontscale .
# mkfontdir .
# xset fp rehash # if X is already running....
#
# Non-packaged TrueType (TTF) fonts should be installed similarly in ~/.fonts:
#
# Note that OpenType (OTF) fonts don't work even if they are _also_ installed on
# the client system. They can be listed by xlsfonts, but not opened! See:
#
# https://stackoverflow.com/questions/57078805/xloadqueryfont-fails-on-font-found-with-xlistfonts
#
# FontConfig is a stupid STUPID design! Having to have fonts installed on the
# both client and server is STUPID! Configuration files in XML are STUPID!
#
if [ ! -d ${HOME}/.fonts ]; then
echo "$argv0: making a new empty ~/.fonts directory!"
echo "$argv0: NOTICE: you may need to install some TTF fonts here (e.g. DejaVu)!"
mkdir ${HOME}/.fonts
fi
#
if [ -r ${HOME}/.fonts.alias.m4 ]; then
# n.b.: note the abuse of xrdb and the custom use of m4!
xrdb -quiet -cpp m4 -E -n ${HOME}/.fonts.alias.m4 | sed 1,2d > ${HOME}/.fonts/fonts.alias
fi
#
# XQuartz comes with a script called "font_cache" that is run (if the preference
# "org.xquartz.X11 cache_fonts" is true) by startx (and privileged_startx) that
# does this and more for all standard font directories on macos.
#
# XXX However since we have possibly created or updated the fonts.alias file we
# must re-run mkfontdir!
#
# XXX If a private "~/.fonts/encodings" directory is needed, add it here too!
#
MKF_ENC=${X11FONTDIR}/encodings
mkfontscale -a ${MKF_ENC} -a ${MKF_ENC}/large -- ${HOME}/.fonts
mkfontdir -e ${MKF_ENC} -e ${MKF_ENC}/large -- ${HOME}/.fonts
#
if [ -n "${X11FONTPATH}" ]; then
echo "$argv0: initial X11FONTPATH=${X11FONTPATH}"
fi
# xxx ~/.fonts should always come first!
fpappend X11FONTPATH "${HOME}/.fonts/"
if [ -d ${HOME}/Library/Fonts ]; then
for fd in $(find "${HOME}/Library/Fonts" -type d) ; do
fpappend X11FONTPATH ${fd}
done
fi
fpappend X11FONTPATH "${LOCAL}/share/fonts/X11/TTF/" "${LOCAL}/share/fonts/X11/OTF/" "${LOCAL}/share/fonts/X11/Type1/"
fpappend X11FONTPATH "${PKG}/share/fonts/X11/TTF/" "${PKG}/share/fonts/X11/OTF/" "${PKG}/share/fonts/X11/Type1/"
fpappend X11FONTPATH "${PKG}/share/fonts/X11/intlfonts/TrueType" "${PKG}/share/fonts/X11/intlfonts/Type1"
#
# now for the standard X11 fonts, preferring scalable fonts of course!
#
fpappend X11FONTPATH "${X11FONTDIR}/TTF/" "${X11FONTDIR}/OTF/"
#
# N.B.: If you've set the "cursor" alias then this may be where it is from,
# unless you've had to install it (i.e. "cursor.pfa") locally in your ~/.fonts
# directory.
#
fpappend X11FONTPATH "${X11FONTDIR}/Type1/"
#
# The next is of course just for OS X:
#
# (see /opt/X11/bin/font_cache)
#
# XXX these are not usable on older macos, e.g. 10.13.... hmmmm.... maybe we
# just leave these to fontconfig?
#
#fpappend X11FONTPATH "${X11PATH}/share/system_fonts/" "${X11PATH}/share/system_fonts/Supplemental"
#
# Don't bother with unscalable fonts on high-res systems...
#
# XXX this assumes we have a modified fonts.alias though!
#
if [ $SCREENDPI_Y -lt 110 ]; then
: so this block can be commented out for testing but for this line
#
### xxx n.b.: misc has "nil2", for which there doesn't seem to be a
### scalable variant, but do we really need it? It only seems to be
### used by Xterm for the default "Unreadable" font (which we override
### anyway).
#
# XXX this/these give Ctwm's "identify" window a nicer, smaller ("normal
# sized"?) font on the iMac27 (the :unscaled variants above do not).
#
# N.B.: The ":unscaled" suffix is undocumented (at least in xset(1))
# (it is mentioned as a "hack" in the main "Fonts in X11" document). It
# prevents the server from scaling bitmap fonts, avoiding pixelation and
# other weird artifacts.
#
fpappend X11FONTPATH "${X11FONTDIR}/100dpi/:unscaled"
#
# "misc" should come last, but must be present
#
# (XXX unless an equivalent fonts.alias is available elsewhere(?), which
# of course it does with my ~/.fonts/fonts.alias, but beware that it
# contains many of the same alias names pointing at scalable fonts!)
#
fpappend X11FONTPATH "${X11FONTDIR}/misc/:unscaled"
fi
#
if xset q | sed -n '/^Font/ {n;p;}' | fgrep built-ins 2>&1 >/dev/null; then
X11FONTPATH="${X11FONTPATH},built-ins"
fi
#
echo "$argv0: final X11FONTPATH='$X11FONTPATH'" | sed 's/:/: /g' | fold -s
export X11FONTPATH
#
# finally we can set and activate the new font path
#
xset fp= "${X11FONTPATH}"
xset fp rehash
fc-cache -v
##################
if ! $DEBUG; then
set -x
fi
xdpyinfo
#xrdb -query -all
xset q
if [ -n "$XNESTDISPLAY" ]; then
xset -display ${XNESTDISPLAY} q
fi
xlsfonts > $HOME/tmp/xlsfonts.out
## /Users/woods/.fonts/,/Users/woods/Library/Fonts,/opt/pkg/share/fonts/X11/TTF/,/opt/pkg/share/fonts/X11/intlfonts/TrueType,/opt/pkg/share/fonts/X11/intlfonts/Type1,/opt/X11/share/fonts/TTF/,/opt/X11/share/fonts/OTF/,/opt/X11/share/fonts/Type1/,/opt/X11/share/system_fonts/,/opt/X11/share/system_fonts/Supplemental
## /Users/woods/.fonts/,/opt/X11/share/fonts/TTF/,/opt/X11/share/fonts/OTF/,/opt/X11/share/fonts/Type1/,/opt/X11/share/system_fonts/,/opt/X11/share/system_fonts/Supplemental
xlsfonts -fn "${DecentFontSpecL1}"
xlsfonts -fn "${DecentFontSpec}"
xlsfonts -o -fn "${DecentFontSpec}"
#
xlsfonts -fn "-xfree86-cursor-medium-r-normal--0-160-218-218-p-0-adobe-fontspecific"
xlsfonts -o -fn "-xfree86-cursor-medium-r-normal--0-160-218-218-p-0-adobe-fontspecific"
xlsfonts -fn "cursor"
xlsfonts -o -fn "cursor"
#
if ! $DEBUG; then
set +x
fi
##################
#
# now in case we've updated the "cursor" alias....
#
xsetroot -cursor_name tcross
if [ $argv0 = ".xsession" -a -z "$XDMHOST" ]; then
case "${HOSTNAME}${DOMAINNAME}" in
*${DOMAINNAME})
XDMHOST=${HOSTNAME}
;;
*)
XDMHOST=${HOSTNAME}${DOMAINNAME}
;;
esac
export XDMHOST # also used by .[c]twmrc
echo "$argv0: have set XDMHOST='$XDMHOST'"
fi
# Align the xconsole at the bottom of the screeen to the workspace manager at
# the top of the screen....
#
# xxx at the moment nothing in ~/.ctwmrc needs $Xconsole*, but instead we pass
# it $XTERM_LITTLE_OPTS (which is using these calculations) trough the environ.
#
XconsoleWidth=$(expr ${WSOff} + ${WSWidth})
if [ $SCREENSIZE_Y -gt 3000 ]; then
XconsoleHeight=$(expr ${SCREENDPI_Y} \* 2) # 2 inches
elif [ $SCREENSIZE_Y -ge 1440 ]; then
# this should give 130 on the 27" iMac, matching my old pixel setting
XconsoleHeight=$(expr ${SCREENDPI_Y} \* 12 / 10) # 1.2 inches
else
XconsoleHeight=$(expr ${SCREENDPI_Y} \* 1) # 1 inch
fi
# n.b. not sure why there was only one borderWidth involved originally!
XconsoleVoff=$(expr ${XconsoleHeight} + ${TitleHeight} + ${TDBorderWidth} + ${TDBorderWidth} + ${TDBorderWidth})
case "$DISPLAY" in
:[0-9]*)
#
# OK, so if we're running on the system console there's a good chance
# the user will never see system messages sent to /dev/console so we
# will try to run xconsole and also redirect our own output to
# /dev/console so that window manager and application errors will also
# go to the xconsole window. Unfortunately there's no logging to a
# permanent file this way though...
#
xconsole_args="-geometry ${XconsoleWidth}x${XconsoleHeight}-0-0"
#
xconsole_args=$xconsole_args" -saveLines 2000 -notify -verbose"
#
if [ $(uname -s) = "Darwin" -a -z "${XNESTDISPLAY}" ]; then
#
# XXX n.b.: with the advent of the new Unified Logging System
# XXX and log(1) but with XQuartz not (yet) using os_log(3), so
# XXX 'subsystem == "org.xquartz.X11"' cannot be used, though
# XXX then debug would be too much easier....
#
# XXX the "log" and "awk" may get left behind if nothing ever
# generates another message, and so they never write to the
# closed pipe, and so never get a SIGPIPE....
#
TEN_S_AGO=$(date -r $(($(date '+%s') - 10)) '+%Y-%m-%d %H:%M:%S''%z')
{
log show --info --debug --predicate 'process == "launchd_startx" || process == "privileged_startx"' --style compact --start "${TEN_S_AGO}"
log stream --level debug --predicate 'process == "launchd_startx" || process == "privileged_startx"' --style compact
} | awk '{
match($0, /[^\]]*\][^\])]*[\])] /);
print substr($0, 1, 24) substr($0, (RLENGTH > 0) ? RLENGTH : 25);
fflush();
}' | xconsole $xconsole_args -file /dev/stdin &
#
#
# don't bother with this unless it'll do us some good though...
# (i.e. unless XDM ran the GiveConsole script)
#
elif [ $(uname -s) != "Darwin" -a -w /dev/console ]; then
ONCONSOLE=true
xconsole $xconsole_args &
# wait a wee bit in hopes xconsole gets running to display any errors....
sleep 1
elif [ "$argv0" = ".xinitrc" ]; then
#
# XXX I think this "tail" could get left behind if nothing ever
# writes to the file it is watching (so it will never write
# anything more to the closed pipe, and so never get a
# SIGPIPE....
#
if [ -r $HOME/.xinit-errors ]; then
tail -F $HOME/.xinit-errors | xconsole $xconsole_args -file /dev/stdin &
else
echo "$argv0: WARNING: startx/xinit output not going to ~/.xinit-errors?"
fi
elif [ "$argv0" = ".xsession" ]; then
# XXX again, beware of lost tails...
if [ -r $HOME/.xsession-errors-$DISPLAY ]; then
tail -F $HOME/.xsession-errors-$DISPLAY | xconsole $xconsole_args -file /dev/stdin &
elif [ "$XODISPLAY" != "$DISPLAY" -a -r $HOME/.xsession-errors-$XODISPLAY ]; then
tail -F $HOME/.xsession-errors-$XODISPLAY | xconsole $xconsole_args -file /dev/stdin &
else
echo "$argv0: didn't find ~/.xsession-errors-$DISPLAY, assuming old XDM config in use"
tail -F $HOME/.xsession-errors | xconsole $xconsole_args -file /dev/stdin &
fi
else
echo "$argv0: WARNING: display was '$DISPLAY' but /dev/console is not writable by ${USER:-$LOGNAME}!"
fi
# Now since $DISPLAY doesn't have a hostname we need to figure out what
# name to use so that remotely running clients can connect back to this
# Xserver...
#
# N.B.: This first test, per chance, also excludes Darwin hosts,
# handled above....
#
if [ ! -w /dev/console -a -n "${XDMHOST}" ]; then
#
# If $XDMHOST is set then assume we are on a fixed xterminal or
# "diskless" workstation on a LAN and that we will commonly be
# using X applications running on other local servers, including
# $X11SERVER which will be set below.
#
# For diskless workstations the use of a few local applications
# with a $DISPLAY set to include the network name is usually
# acceptable.
#
DISPLAY="${XDMHOST}${DISPLAY}"
echo "$argv0: have set DISPLAY='$DISPLAY' using XDMHOST, setting REMOTE_DISPLAY to match"
#
# we should not need to set this here, but it does make .ctwmrc
# simpler....
#
REMOTE_DISPLAY="${DISPLAY}"
else
# assume we are on a (mobile?) workstation (laptop?) or some
# similar host where X is started with startx (i.e. not XDM),
# e.g. XQuartz on Darwin, and that we will normally run all of
# our applications either locally or via RSH, or SSH tunnels,
# etc., so we keep the short-form $DISPLAY for local clients and
# set $REMOTE_DISPLAY to a name that hopefully they can resolve
# to an address by which they can connect back to this Xserver.
#
# so, using the local short-form ":N.n" syntax is supremely
# preferred for the local host as it should use its local Unix
# socket.
#
# XXX ${DOMAINNAME} is probably not right here....
# XXX and if so, ${HOSTNAME} must be something remote
# XXX client hosts understand
#
case "$HOSTNAME" in
*.*)
REMOTE_DISPLAY="${HOSTNAME}${DISPLAY}"
;;
*)
REMOTE_DISPLAY="${HOSTNAME}${DOMAINNAME}${DISPLAY}"
;;
esac
echo "$argv0: for DISPLAY='$DISPLAY' have set REMOTE_DISPLAY='$REMOTE_DISPLAY'"
fi
;;
esac
export REMOTE_DISPLAY
export DISPLAY
if [ "$XODISPLAY" != "$DISPLAY" ]; then
echo "$argv0: notice: XODISPLAY='$XODISPLAY', DISPLAY='$DISPLAY'"
fi
# may be things that depend on DISPLAY in here, so source it again....
#
if [ -r $HOME/.localprofile ]; then
. $HOME/.localprofile < /dev/null
fi
if [ -z "$LONGITUDE" ]; then
# kelowna, bc
#LATITUDE="49.87157"
#LONGITUDE="-119.49038"
# Avoncote Farm (gives XEarth a nice(r) view of Canada too)
LATITUDE=50.14349201581629
LONGITUDE=-101.77988255896784
export LATITUDE LONGITUDE
fi
# Possibly needed xmodmap fixups....
#
# Unfortunately there is no real way to tell what type of keyboard is
# attached and no way to revert unknown earlier changes, so instead we
# must just rely on the display name to know what keyboard is attached.
#
#case "$VENDORSTR" in
#*"Network Computing Devices"*)
case $DISPLAY in
xtra*:*|xtremely*:*)
if [ -r $HOME/.Xmodmap-ncd-108 ]; then
case "$XDMHOST" in
proven.weird.com|starting-out.weird.com)
# should have been done by xdm setup script....
echo "$argv0: NOT setting NCD keyboard map on $XDMHOST!"
;;
*)
echo "$argv0: setting NCD keyboard map from $HOME/.Xmodmap-ncd-108"
xmodmap $HOME/.Xmodmap-ncd-108
;;
esac
else
echo "$argv0: $HOME/.Xmodmap-ncd-108 not found!"
fi
;;
wayback*:*)
if [ -r $HOME/.Xmodmap-reverse-scroll ]; then
xmodmap $HOME/.Xmodmap-reverse-scroll
fi
;;
esac
# TODO: allowing the local host might be a mistake (since other users
# might also have access to the local host), but doing so might save
# your bacon if xdm or xinit has not set up ~/.Xauthority correctly!
#
# xxx xhost tries to open a font for some unknown reason!
#
xhost +$(hostname) +localhost +local: -
# deprecated xhost crap
#
if [ -r $HOME/.xhosts ]; then
echo "$argv0: now setting up all the DANGEROUS deprecated xhost access controls!"
while read XHOST junk; do
case "$XHOST" in
""|'#'*)
;;
*)
# NEVER remove the "" from the first clause!!!
xhost +$XHOST
;;
esac
done < $HOME/.xhosts
fi
if [ -z "$WM" ]; then
echo "$argv0: searching for a usable window manager..."
#
# XXX maybe it would be nice to have a window-manager-chooser, which is
# effectively what a modern "session" manager is... but xsm(1) isn't
# really that modern, and it's the only thing available by default, and
# it wants to be started instead of the window manager. Even xsm(1)
# though can do all the secondary app startups, in theory, but it seems
# it needs the deprecated rstart(1) and friends to start programs on
# remote machines, and:
#
# *** rstart and iceauth should be installed on each machine that you expect
# to run applications on that will be part of your session ***
#
if type ctwm >/dev/null 2>&1; then
#
# N.B.: in newer versions (>= 4.x) a new command-line syntax
# makes use of "-display $DISPLAY" break. However since well
# before 3.8.2 the default is the $DISPLAY in the environment,
# so we can just avoid using it at all.
#
if [ ${SCREENDEPTH:-1} -eq 1 ]; then
# the welcome screen on monochrome is silly and slow
WM="ctwm -v -k -K $HOME/.ctwmrc.m4out -W"
else
WM="ctwm -v -k -K $HOME/.ctwmrc.m4out"
fi
# force activeIcon on for ctwm, though it may not be used if an
# IconManager is in use for Xterm windows....
#
XTERM_OPTS="+ai ${XTERM_OPTS}"
elif type etwm >/dev/null 2>&1; then
# Brian Bidulock's "Enhanced TWM", forked from CTWM, possibly dead
# https://github.com/bbidulock/etwm
#
WM=etwm
XTERM_OPTS="+ai ${XTERM_OPTS}"
elif type adwm >/dev/null 2>&1; then
# Brian Bidulock's "advanced dynamic window manager" for his(?)
# XDE (X Desktop Environment)
# https://github.com/bbidulock/xde-desktop
#
WM=adwm
elif type tvtwm >/dev/null 2>&1; then
WM=tvtwm
elif type wmx >/dev/null 2>&1; then
WM=wmx
elif type wm2 >/dev/null 2>&1; then
WM=wm2
elif type scwm >/dev/null 2>&1; then
WM=scwm
elif type wmaker >/dev/null 2>&1; then
WM=wmaker
elif type fvwm >/dev/null 2>&1; then
WM=fvwm
elif type twm >/dev/null 2>&1; then
WM="env LC_ALL=C twm -v -v"
XTERM_OPTS="+ai ${XTERM_OPTS}"
else
echo "$argv0: assuming 'xterm' is available in lieu of a known WM..."
WM=xterm
fi
export WM
fi
echo "$argv0: WM='${WM}'"
# XTerm options which cannot to be set consistently with resources, ("+ai" may
# be added below, depending on which window manager is used), or which should
# not because they depend on other things in the environment, such as which
# window manager is being used.
#
# n.b.: this is also set in ~/.profile, and should be identical
#
if [ -z "$XTERM_OPTS" ]; then
XTERM_OPTS=""
fi
export XTERM_OPTS
# Notes:
#
# - setting -fs (faceSize) to 7.5 makes the TrueType font size most closely
# match the size of the default "fixed" bitmap font's size (as it was on a
# 100dpi display).
#
# - Unfortunately on both the iMac 27" (at 2560x1440) and the Retina 6K XDR Pro
# there is not quite room enough horizontally for the three standard xterms
# (two at 132 cols, one at +80 cols) with a point size of 9 for the big ones,
# but 9pt is quite readable anyway.
#
# XXX with a laptop in the range of 300mmx200mm we want no more than 60x132 -fs 7.5
#
# XXX to accurately calculate a fit onto the screen we would need to use
# xprop(1) or xwininfo(1) (-size) and an existing window displaying the desired
# font size. This would give us the character cell size ("program specified
# resize increment"). So far the only way I can think of doing this is to start
# one or more test xterms (one for each desired font size) and have them run
# xwininfo to find out about their own WM size hints, but this would require
# using a temporary file (and then parsing its contents):
#
# xterm -fs 9 -e 'xwininfo -id $WINDOWID -size > $HOME/tmp/xwi.out; exit'
#
if [ ${SCREENDIM_Y} -ge 14 ]; then
# Mac 32" 6k XDR Pro
XTERM_BIG_OPTS="-geometry 132x100+0+0 -fs ${DecentPt}"
elif [ ${SCREENDIM_Y} -ge 13 ]; then
# iMac 27"
XTERM_BIG_OPTS="-geometry 117x93+0+0 -fs ${DecentPt}"
elif [ ${SCREENDIM_Y} -ge 11 ]; then
# Xnest on the 32" XDR Pro
XTERM_BIG_OPTS="-geometry 102x74+0+0 -fs ${DecentPt}"
elif [ ${SCREENDIM_Y} -ge 8 ]; then
# xxx untested
XTERM_BIG_OPTS="-geometry 132x66+0+0 -fs ${SmallerPt}"
elif [ ${SCREENDIM_Y} -ge 6 ]; then
# "13-inch" laptop
XTERM_BIG_OPTS="-geometry 132x54+0+0 -fs ${SmallerPt}"
else
# xxx untested
XTERM_BIG_OPTS="-geometry 80x30+0+0 -fs ${TinyPt}"
fi
export XTERM_BIG_OPTS
# With CommitMono font this could be 51 high
# With DejaVu Sans Mono this could be 45 high
# With Liberation Mono this could be 47 high
# With .sf ns mono (apple) this could be 49 high
# With CommitMono and DejaVu Sans Mono fonts this could be 91 wide
# With Liberation Mono and .sf ns mono (appl) this could be 92 wide
#
# XXX with a laptop in the range of 300mmx200mm we want no more than 80x40 -fs 6
#
# (e.g. 91x45, 95x50), or taller, or shorter.... (calculate based on character
# size (see above about 'xwininfo -size') and $XconsoleWidth and something
# related to IR_GEOM vs. $XconsoleHeight)
#
# N.B.: for the '-T OccupyAll' to work the terminal must be started after the
# window manager is running, so put a little sleep in front of ones using these
# flags....
#
if [ ${SCREENDIM_Y} -ge 14 ]; then
# Mac 32" 6k XDR Pro
XTERM_LITTLE_OPTS="-geometry 91x47-0-${XconsoleVoff} -fs ${SmallerPt} -T OccupyAll"
elif [ ${SCREENDIM_Y} -ge 13 ]; then
# iMac 27"
XTERM_LITTLE_OPTS="-geometry 98x47-0-${XconsoleVoff} -fs ${SmallerPt} -T OccupyAll"
elif [ ${SCREENDIM_Y} -ge 11 ]; then
# Xnest on the 32" XDR Pro
XTERM_LITTLE_OPTS="-geometry 80x33-0-${XconsoleVoff} -fs ${SmallerPt} -T OccupyAll"
elif [ ${SCREENDIM_Y} -ge 8 ]; then
# xxx untested
XTERM_LITTLE_OPTS="-geometry 80x30-0-${XconsoleVoff} -fs ${TinyPt} -T OccupyAll"
elif [ ${SCREENDIM_Y} -ge 6 ]; then
# "13-inch" laptop
XTERM_LITTLE_OPTS="-geometry 80x24-0-0 -fs ${TinyPt} -T OccupyAll"
else
# xxx untested, probably no space anyway!
XTERM_LITTLE_OPTS="-geometry 80x24-0-0 -fs ${TinyPt} -T OccupyAll"
fi
export XTERM_LITTLE_OPTS
# on OSX Xterm isn't configured to record logins properly with "-ls", but if we
# start login(1) instead then it will record the login session.
#
# N.B.: because this contains another variable expansion the command must be
# started with "eval"
#
if [ $(uname -s) = "Darwin" ]; then
XTERM_LOGIN_OPTS="-e login -pf ${USER:-$LOGNAME}"
export XTERM_LOGIN_OPTS
fi
HAVESWISSWATCH=false ; export HAVESWISSWATCH
if type swisswatch >/dev/null 2>&1; then
HAVESWISSWATCH=true
fi
HAVEXBUFFY=false ; export HAVEXBUFFY
if type xbuffy >/dev/null 2>&1; then
HAVEXBUFFY=true
fi
HAVEXBIFF=false ; export HAVEXBIFF
if type xbiff >/dev/null 2>&1; then
HAVEXBIFF=true
fi
HAVEXEARTH=false ; export HAVEXEARTH
if type xearth >/dev/null 2>&1; then
HAVEXEARTH=true
fi
HAVEXPLANET=false ; export HAVEXPLANET
if type xplanet >/dev/null 2>&1; then
HAVEXPLANET=true
fi
HAVEXPHOON=false ; export HAVEXPHOON
if type xphoon >/dev/null 2>&1; then
HAVEXPHOON=true
fi
HAVEXV=false ; export HAVEXV
if type xv >/dev/null 2>&1; then
HAVEXV=true
fi
HAVEIMAGEMAGICK=false ; export HAVEIMAGEMAGICK
if type display >/dev/null 2>&1; then
HAVEIMAGEMAGICK=true
fi
# If you're running on a diskless workstation that runs xdm itself
# then you probably have a server that's more powerful and on which
# you'd rather run the majority of your X applications. Normally
# this will be the same server your home directory resides on....
#
if [ -n "$XDMHOST" -a "$XDMHOST" = "$(echo $DISPLAY | sed 's/:.*$//')" ]; then
echo "$argv0: looks like '$XDMHOST' is running xdm for our display..."
case "$XDMHOST" in
almost.weird.com)
X11SERVER=${X11SERVER:-"most.weird.com"}
export X11SERVER
echo "$argv0: have set X11SERVER='$X11SERVER'"
;;
very.weird.com|very.robohack.planix.com)
X11SERVER=${X11SERVER:-"once.weird.com"}
export X11SERVER
echo "$argv0: have set X11SERVER='$X11SERVER'"
;;
*)
# not setting X11SERVER hopefully just makes the WM run all
# X11SERVER clients on the current login host.... unless it can
# and does eliminate the menu entries entirely!
unset X11SERVER
echo "$argv0: have unset X11SERVER; XDMHOST is $XDMHOST"
;;
esac
#
# Common for all xdm startups
#
# XXX anything special???
fi
# else...
# argv0 is .xinitrc if called by xinit or startx
#
if [ "$argv0" = ".xinitrc" ]; then
echo "$argv0: looks like X was started with xinit or startx..."
#
# setup for "remote" windows
#
case $DISPLAY in
:*)
case $REMOTE_DISPLAY in
very.local:*|very-old.local:*)
;;
esac
;;
almost.weird.com)
X11SERVER=${X11SERVER:-"most.weird.com"}
export X11SERVER