aboutsummaryrefslogtreecommitdiff
path: root/bin/icd
blob: fec5d5f714c053f842c9fbda165ea5a8f7a99afa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh

GLOBAL_OPTIONS="\
    -option terminate:ctrl_alt_bksp \
    -option nbsp:level3n \
    -I${HOME}/.xkb \
    -layout icd,dpr \
    -variant icd,dpr \
    -option grp:shifts_toggle"

OPTIONS="\
    ${GLOBAL_OPTIONS} \
    -option lv3:ralt_switch_multikey \
    -option ctrl:swapcaps"

setxkbmap ${OPTIONS} -print > ${HOME}/.xkb/keymap/icd

SUN_USB_ID=$(lsusb | grep Sun | awk '{ print $6 }')
KIN_USB_ID=$(lsusb | grep -i "Kinesis Advantage Pro" | awk '{ print $6 }')

if [ "x${SUN_USB_ID}" != "x" ]; then
    SUN_XINPUT_ID=$(xinput | grep ${SUN_USB_ID} | sed -e 's/.*id=\([0-9]\+\).*/\1/g')
    setxkbmap \
        -I${HOME}/.xkb \
        -keycodes "rak" \
        -device ${SUN_XINPUT_ID} \
        -geometry "sun(type6)" \
        ${OPTIONS} \
        -print > ${HOME}/.xkb/keymap/icd.sun
#    awk '{ \
#        if (/symbols/) { \
#            sub(/\)\"/, ")+myswap(switch_lalt_lsuper)\""); print \
#        } else { \
#            print \
#        } \
#    }' ${HOME}/.xkb/keymap/icd.sun2 > ${HOME}/.xkb/keymap/icd.sun
    xkbcomp -i ${SUN_USB_ID} -I${HOME}/.xkb \
        ${HOME}/.xkb/keymap/icd.sun ${DISPLAY} # 2> /dev/null
        #xkbcomp -i ${SUN_USB_ID} -I${HOME}/.xkb \
        #    ${HOME}/.xkb/symbols/myswap ${DISPLAY} # 2> /dev/null
elif [ "x${KIN_USB_ID}" != "x" ]; then
    KIN_XINPUT_ID=$(xinput | grep ${KIN_USB_ID} | sed -e 's/.*id=\([0-9]\+\).*/\1/g')
    for XID in $KIN_XINPUT_ID; do
        echo $XID
        setxkbmap \
            -I${HOME}/.xkb \
            -device ${XID} \
            ${GLOBAL_OPTIONS} \
            -option "lv3:switch" \
            -option "caps:swapescape" \
            -print | sed -e 's@+ctrl(nocaps)@@g' > ${HOME}/.xkb/keymap/icd.kin
        xkbcomp -i ${XID} -I${HOME}/.xkb \
            ${HOME}/.xkb/keymap/icd.kin ${DISPLAY} # 2> /dev/null
    done
    xkbcomp -I${HOME}/.xkb \
        ${HOME}/.xkb/keymap/icd.kin ${DISPLAY} # 2> /dev/null
else
    xkbcomp -I/home/ryan/.xkb \
        /home/ryan/.xkb/keymap/icd $DISPLAY # 2> /dev/null
fi

echo icd > /home/ryan/.xmonad/layout