]> git.madduck.net Git - etc/xsession.git/blob - .xsession.d/01-xkb

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

0e50c36826887ae5980c95d2befeb5391ae51c79
[etc/xsession.git] / .xsession.d / 01-xkb
1 # load the keyboard definitions
2
3 LAYOUT=us
4 OPTS=(madduck:mode_switch madduck:group2_intl madduck:caps_mod4)
5
6 is_thinkpad() {
7   case "${(%):-%m}" in
8     lapse) return 0;;
9     *) return 1;;
10   esac
11 }
12
13 load_keymap() {
14   local xkbdir; xkbdir=$HOME/.xkb
15   local model; model="$1"; shift
16   local layout; layout="$1"; shift
17
18   local args; args="-I -I$xkbdir -model $model -layout $layout -option"
19   args="$args -option ${(j: -option :)@}"
20
21   info "running setxkbmap with args: $args"
22   local tmpfile; tmpfile="$(tempfile -p kbmap)"
23   trap "rm -f $tmpfile" EXIT
24   eval setxkbmap $args -print >| "$tmpfile"
25   info keymap setting follows:
26   cat "$tmpfile" >&2
27   xkbcomp -I$HOME/.xkb "$tmpfile" ${DISPLAY%%.*}
28 }
29
30 if is_thinkpad; then
31   info "loading keymap for thinkpad…"
32   load_keymap thinkpad us ${(z)OPTS}
33 else
34   info "loading pc104 keymap…"
35   load_keymap pc104 us ${(z)OPTS}
36 fi
37
38 unset OPTS
39 unset LAYOUT
40
41 # vim:ft=zsh