5.4 KiB
X11 Configuration
X11 is a version of the X Window System[fn::Yep, they have a one-letter domain name.] that is widely used as the graphical environment on many Unix-based systems. There are various implementations, but X.org is standard on most free (as in freedom) desktops.
Session Initialization
The file ~/.xinitrc
is used by X11 when no other configuration script is
provided (e.g. when running startx
from the command line; see
xinit(1)
). This is how I usually start my session.
# <<_inc/prog.org:prog-header("Executed when no display manager is used", "2014, 2015")>>
##
But if the session is started by some other means—the common case being a
display manager—then its own configuration file is used instead. To allow
users to configure their environment, the script .xprofile
is executed (if
it exists) before the window manager is started.
test -f ~/.xprofile && source ~/.xprofile
Since the execution of .xinitrc
implies that no display manager was used,
invoke my window manager: XMonad.[fn::Recall that exec
replaces the
running process, meaning that the .xinitrc
script will not linger.]
exec xmonad
I share my configuration file between multiple environments, so to avoid
frustration, I defer all X configuration to .xprofile
.
# <<_inc/prog.org:prog-header("Executed before window manager", "2014, 2015")>>
##
Keyboard Layout
My keyboard layout is largely a vanilla en_US layout with one important modification: I map the caps lock key to control (the original left-control key remains functional). The control key is very awkward to press and can quickly cause pain in the hand and wrist when using programs that make aggressive use of it (such as Emacs). The caps lock key is a key that is rarely used and in a position that is exceptionally easy to press, so it is often remapped.1[argue against]] such a remapping. While I see the merit of some of the arguments, I have been using Caps Lock as my control key for years quite comfortably. Further, since my Control keys still work, I will use them when it makes ergonomic sense to do so.]
setxkbmap -option ctrl:nocaps
I used to do additional keyboard layout customization in the past, but I've
found that many of my changes were not all that useful. If there are
additional layout changes, they're performed via .xmodmap
:
xmodmap ~/.xmodmap
Mouse
The default mouse cursor for X11 is a black "x". Changing it to arrow
yields the conventional arrow cursor.
xsetroot -cursor_name arrow
Mouse speed is controlled by two parameters: acceleration and threshold. Once the mouse movement reaches the provided threshold within 10ms, its movement is multiplied by the given acceleration—this allows the use to make precision movements when the mouse is moved slowly, while still being able to rapidly move the cursor from one point to another.
I don't have much rationale for my chosen values; they just work well for me. I use the mouse primarily for web browsing, but otherwise my work is almost entirely in a terminal.
xset mouse 5/0.1
Root
The X root window is the background window that you see underneath all other windows. Most people refer to this as the "desktop", but without software to actually produce a desktop, the root is non-interactive. I have no desktop.[fn::For example, GNOME has Nautilus as both its desktop and file manager.]
The default root renders a 1x1px-checkered background, which is useful for showing that X is actually running, but not very appealing. Since I use a tiling window manager (XMonad), I never see my root unless I switch to a workspace with no windows, so I just set it to black.
xsetroot -bg black
Resources
.Xresources
is the file traditionally used to provide key-value pairs for
configuring X11 programs (such as fonts, colors, menus, and other
features). I prefer a more modular approach: I instead have an
.Xresources.d
directory, which contains resource files that will be
merged; this will take precedence over any .Xresources
file if there are
key conflicts.
xrd="$HOME/.Xresources.d"
test -f ~/.Xresources && xrdb -merge ~/.Xresources
test -d "$xrd" && {
for xr in "$xrd"/*; do
xrdb -merge "$xr"
done
}
Screensaver
I use xscreensaver
with my own daemon script that watches for status
changes to perform certain actions. Since I share this configuration on
multiple systems, I permit an opt-out by touching .noscreensaver
.
# screensaver can be disabled by creating ~/.noscreensaver (not managed)
test -f ~/.noscreensaver || {
xscreensaver &
xscreensaver-watchd 2>~/.xscreensaver-watch.log &
}