1
0
Fork 0
dotfiles/src/x11.org

143 lines
5.4 KiB
Org Mode
Raw Permalink Normal View History

#+TITLE: X11 Configuration
#+AUTHOR: Mike Gerwitz
#+EMAIL: mtg@gnu.org
X11 is a version of the [[http://www.x.org/][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 [[https://wiki.freedesktop.org/www/][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.
#+HEADER: :shebang "#!/bin/sh"
#+HEADER: :exports none
#+BEGIN_SRC sh :tangle .xinitrc :noweb yes :padline no
# <<_inc/prog.org:prog-header("Executed when no display manager is used", "2014, 2015")>>
##
#+END_SRC
But if the session is started by some other means---the common case being a
[[https://wiki.archlinux.org/index.php/Display_manager][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.
#+BEGIN_SRC sh :tangle .xinitrc
test -f ~/.xprofile && source ~/.xprofile
#+END_SRC
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.]
#+BEGIN_SRC sh :tangle .xinitrc
exec xmonad
#+END_SRC
I share my configuration file between multiple environments, so to avoid
frustration, I defer all X\nbsp{}configuration to =.xprofile=.
#+HEADER: :shebang "#!/bin/sh"
#+HEADER: :exports none
#+BEGIN_SRC sh :tangle .xprofile :noweb yes :padline no
# <<_inc/prog.org:prog-header("Executed before window manager", "2014, 2015")>>
##
#+END_SRC
** 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.[fn::Some [[http://ergoemacs.org/emacs/swap_CapsLock_Ctrl.html][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.]
#+BEGIN_SRC sh :tangle .xprofile
setxkbmap -option ctrl:nocaps
#+END_SRC
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=:
#+BEGIN_SRC sh :tangle .xprofile
xmodmap ~/.xmodmap
#+END_SRC
** Mouse
The default mouse cursor for X11 is a black "x". Changing it to =arrow=
yields the conventional arrow cursor.
#+BEGIN_SRC sh :tangle .xprofile
xsetroot -cursor_name arrow
#+END_SRC
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.
#+BEGIN_SRC sh :tangle .xprofile
xset mouse 5/0.1
#+END_SRC
** 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.
#+BEGIN_SRC sh :tangle .xprofile
xsetroot -bg black
#+END_SRC
** 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.
#+BEGIN_SRC sh :tangle .xprofile
xrd="$HOME/.Xresources.d"
test -f ~/.Xresources && xrdb -merge ~/.Xresources
test -d "$xrd" && {
for xr in "$xrd"/*; do
xrdb -merge "$xr"
done
}
#+END_SRC
** 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=.
#+BEGIN_SRC sh :tangle .xprofile
# screensaver can be disabled by creating ~/.noscreensaver (not managed)
test -f ~/.noscreensaver || {
xscreensaver &
xscreensaver-watchd 2>~/.xscreensaver-watch.log &
}
#+END_SRC