# ====================[ .xinitrc                           ]====================
#                     [ Time-stamp: "2008-03-11 20:50:08 leycec" ]
#
# This script is run when running "startx", initially.
#
# --------------------( PRECEDENCE                         )--------------------
# This script takes precedent over the system-wide analogue of this script,
# "/etc/X11/xinit/xinitrc". According to the "xinit" man-page, "To determine the
# client to run, startx first looks for a file called .xinitrc in the user's
# home directory. If that is not found, it uses the file xinitrc in the xinit
# library directory, /etc/X11/xinit/xinitrc."
#
# This script, therefore, must perform tasks -- such as importing the
# "/etc/X11/Xmodmap" file -- traditionally performed by that system-wide script.

#FIXME: Enable all "xset" and "xkbset"-related commands if the attached
#keyboard is not a Kinesis. Otherwise, do not. This should probably be
#extracted into a separate "~/bin/" script.
# ....................{ X.ORG PREFERENCES                  }....................
# Set X.org preferences prior to setting Xresources and Xmodmap preferences, as
# the X.org preferences depend on symbolic key mappings modified by the latter.
#
# ....................{ X.ORG PREFERENCES =xset            }....................
# The "xset" command governs runtime X.org preferences. These preferences cannot
# be specified via persisted configuration files, typically; they must be set
# via execution of this command at runtime.

# Enable keyboard auto-repeat for <Caps> and small <Enter>, having keycodes 66
# and 108, respectively.
#xset r 66
#xset r 108

# ....................{ X.ORG PREFERENCES =setxkbmap       }....................
# The "setxkbmap" command also governs runtime X.org preferences: specifically,
# those concerning the keyboard model, layout, et al. from which (specific)
# keyboard components may be selected.
#
# Comment this line if your X.org installation uses pre-X.org 1.5-style input
# configuration via "/etc/X11/xorg.conf" (i.e., not Evdev-managed input for
# "hotplugging" input devices).
#setxkbmap -keycodes evdev -model evdev

# ....................{ X.ORG PREFERENCES =xkbset          }....................
# The "xkbset" command also governs runtime X.org preferences. Unlike "xset,"
# the "xkbset" command is not bundled with X.org but must be installed 
# externally.
#
# See "xkbset h" for details, and "xkbset q" and "xkbset q exp" for all
# currently enabled preferences and expiration preferences.

# Disable the audible bell and feedback.
#
# Enable "sticky keys" for all modifier keys, while also disabling "latchlock"
# (i.e., pressing any modifier key twice in a row permanently locks that key
# on) and disabling "twokey" (i.e., pressing any modifier key and another key
# at the same time permanently disables "sticky keys"). Note that enabling
# "sticky" automatically enables sticky keys for Apple- and Windows-specific
# modifier keys as well, including: <Shift>, <Ctrl>, <Alt>, <Fn>, and <Apple>.
#xkbset -bell -feedback sticky -twokey -latchlock

# Disable expiration of "sticky keys" after the specified time in seconds. When
# expiration is enabled, sticky keys are permanently disabled after that many
# seconds. This is quite unhelpful.
#xkbset exp 64 '=sticky' '=twokey' '=latchlock'

# ....................{ WINDOW MANAGER                     }....................
# Run the "appropriate" window manager as specified by:
source "/etc/rc.conf"

if [ -n "$XSESSION" ]; then
  XSESSION_SCRIPT="/etc/X11/Sessions/$XSESSION"

  if [ -x "$XSESSION_SCRIPT" ]; then
     exec "$XSESSION_SCRIPT"
  else
     echo ".xinitrc: no window manager found!" 1>&2
     exit 1
  fi
else
  echo ".xinitrc: no \"XSESSION\" defined in \"/etc/rc.conf\"!" 1>&2
  exit 1
fi

#if   type -p "fluviola" &> /dev/null; then
#    exec     "fluviola"
#elif type -p "fvwm-crystal" &> /dev/null; then
#    exec     "fvwm-crystal"
#elif type -p "fvwm" &> /dev/null; then
#    exec     "fvwm"
#else
