1XCOMM!SHELL_CMD
2XHASH $NetBSD: xinitrc.cpp,v 1.23 2025/03/09 08:09:32 mrg Exp $
3
4xrdb=XRDB
5xinitdir=XINITDIR
6xclock=XCLOCK
7xterm=XTERM
8uxterm=UXTERM
9twm=TWM
10xmodmap=XMODMAP
11ctwm=CTWM
12xsetroot=XSETROOT
13
14userresources=$HOME/.Xresources
15usermodmap=$HOME/.Xmodmap
16sysresources=$xinitdir/.Xresources
17sysmodmap=$xinitdir/.Xmodmap
18
19XCOMM merge in defaults and keymaps
20
21if [ -f $sysresources ]; then
22    if [ -x /usr/bin/cpp ] ; then
23        $xrdb -merge $sysresources
24    else
25        $xrdb -nocpp -merge $sysresources
26    fi
27fi
28
29if [ -f $sysmodmap ]; then
30    $xmodmap $sysmodmap
31fi
32
33fontsize=$(/usr/X11R7/libexec/ctwm_font_size)
34if ! [ -n "$fontsize" ]; then
35	fontsize=16
36fi
37
38if [ -f "$userresources" ]; then
39    if [ -x /usr/bin/cpp ] ; then
40        $xrdb -merge "$userresources"
41    else
42        $xrdb -nocpp -merge "$userresources"
43    fi
44else
45    $xrdb -merge - <<EOF
46XHASH ifdef COLOR
47*customization: -color
48XHASH endif
49*VT100.foreground: grey90
50*VT100.background: black
51*SimpleMenu*font:	-*-spleen-medium-r-*-*-$fontsize-*-*-*-*-*-*-*
52*SimpleMenu*menuLabel.font:	-*-spleen-medium-r-*-*-$fontsize-*-*-*-*-*-*-*
53Bitmap*font:    -*-spleen-medium-r-*-*-$fontsize-*-*-*-*-*-*-*
54Editres*font:   -*-spleen-medium-r-*-*-$fontsize-*-*-*-*-*-*-*
55Viewres*font:   -*-spleen-medium-r-*-*-$fontsize-*-*-*-*-*-*-*
56XCalc*font:     -*-spleen-medium-r-*-*-$fontsize-*-*-*-*-*-*-*
57XClipboard*font:        -*-spleen-medium-r-*-*-$fontsize-*-*-*-*-*-*-*
58XConsole*font:  -*-spleen-medium-r-*-*-$fontsize-*-*-*-*-*-*-*
59XFontSel*font:  -*-spleen-medium-r-*-*-$fontsize-*-*-*-*-*-*-*
60XLoad*font:     -*-spleen-medium-r-*-*-$fontsize-*-*-*-*-*-*-*
61Xedit*font:     -*-spleen-medium-r-*-*-$fontsize-*-*-*-*-*-*-*
62Xfd*font:       -*-spleen-medium-r-*-*-$fontsize-*-*-*-*-*-*-*
63Xgc*font:       -*-spleen-medium-r-*-*-$fontsize-*-*-*-*-*-*-*
64Xmag*font:      -*-spleen-medium-r-*-*-$fontsize-*-*-*-*-*-*-*
65Xmessage*font:  -*-spleen-medium-r-*-*-$fontsize-*-*-*-*-*-*-*
66Xmh*font:       -*-spleen-medium-r-*-*-$fontsize-*-*-*-*-*-*-*
67EOF
68if [ $fontsize -gt 18 ]; then
69XCOMM
70XCOMM For HiDPI displays, the font size returned by ctwm_font_size will
71XCOMM generally be a multiple of 16.  96 is our standard DPI, and many
72XCOMM applications want to scale by integer increments or don't handle
73XCOMM non-integer scaling gracefully, so we want to scale by multiples
74XCOMM of 96.
75XCOMM
76    XRDB -merge - <<EOF
77Xft.dpi: $((96 * (fontsize / 16)))
78*VT100.faceName: xft:Monospace:pixelsize=$fontsize
79EOF
80elif [ $fontsize -gt 13 ]; then
81XCOMM
82XCOMM For non-HiDPI cases, use the standard misc-fixed font in xterm
83XCOMM since it has bold variants, and seems to have caused fewer
84XCOMM complaints than alternatives in the community so far.
85XCOMM
86XCOMM Using bitmap instead of TrueType fonts offers us some minor
87XCOMM performance gains on very slow machines.
88XCOMM
89    XRDB -merge - <<EOF
90*VT100.font: -misc-fixed-medium-r-normal-*-18-*-*-*-*-*-iso10646-1
91*VT100.fontBold: -misc-fixed-bold-r-normal-*-18-*-*-*-*-*-iso10646-1
92*VT100.utf8Fonts.font: -misc-fixed-medium-r-normal-*-18-*-*-*-*-*-iso10646-1
93*VT100.utf8Fonts.fontBold: -misc-fixed-bold-r-normal-*-18-*-*-*-*-*-iso10646-1
94EOF
95else
96    XRDB -merge - <<EOF
97*VT100.font: -misc-fixed-medium-r-normal-*-13-*-*-*-*-*-iso10646-1
98*VT100.fontBold: -misc-fixed-bold-r-normal-*-13-*-*-*-*-*-iso10646-1
99*VT100.utf8Fonts.font: -misc-fixed-medium-r-normal-*-13-*-*-*-*-*-iso10646-1
100*VT100.utf8Fonts.fontBold: -misc-fixed-bold-r-normal-*-13-*-*-*-*-*-iso10646-1
101EOF
102fi
103fi
104
105if [ -f "$usermodmap" ]; then
106    $xmodmap "$usermodmap"
107fi
108
109XCOMM start some nice programs
110
111if [ -d $xinitdir/xinitrc.d ] ; then
112	for f in "$xinitdir/xinitrc.d"/?*.sh ; do
113		[ -x "$f" ] && . "$f"
114	done
115	unset f
116fi
117
118$xsetroot -cursor_name left_ptr
119$xsetroot -solid 'rgb:00/22/44'
120$xclock -digital -strftime '%a %Y-%m-%d %H:%M' \
121	-face "spleen:pixelsize=$fontsize" -g +0+0 &
122$uxterm &
123exec $ctwm -W
124