aboutsummaryrefslogblamecommitdiff
path: root/bin/executable_icd
blob: 367b87f25fb20deff42f8e1e74e9df0080be8f7a (plain) (tree)
1
2
3
4
5
6
7
8
9
         
 


                                                      
                 


                    
                                     
                          
                                 
                              
 
                 
                       
                                     
 

                       
                        
                            
 

                       
                              
                         
                             

                                      

                       
                        

                        













                                                                                                      
 
                        
                                                                                      

                                                 
                                                          
 

                                    



                                                                                     
                          
                            
                            
                                                                                                                   
                                                 

                                                                 
                                   
                                                             

                                    

  


                                                                                     
                               





                                 
                                                                                                    


                                                                 

  
                  
                                    
                             
                                                                                                    
                               






                                                


                                                                                                      


                                                                 
 
 
                                 
#!/bin/sh

XKB_DIR=${HOME}/.xkb
[ -d ${XKB_DIR}/keymap ] || mkdir -p ${XKB_DIR}/keymap

GLOBAL_OPTIONS="\
    -I${XKB_DIR} \
    -layout icd,ru \
    -variant icd, \
    -option terminate:ctrl_alt_bksp \
    -option nbsp:level3n \
    -option lalt_meta:lalt_meta \
    -option grp:shifts_toggle"

LAPTOP_OPTIONS="\
    ${GLOBAL_OPTIONS} \
    -option lv3:ralt_switch_multikey"

KIN_OPTIONS="\
    ${GLOBAL_OPTIONS} \
    -option lv3:switch \
    -option caps:swapescape"

SUN_OPTIONS="\
    ${GLOBAL_OPTIONS} \
    -geometry sun(type6unix) \
    -option caps:escape \
    -option lv3:menu_switch \
    -option myswap:switch_lalt_lsuper"

ERG_OPTIONS="\
    ${GLOBAL_OPTIONS} \
    -option lv3:switch \
    -option caps:escape"


case `uname` in
    OpenBSD)
        LAPTOP_ID=$(xinput | grep "/dev/wskbd" | sed -e 's/.*id=\([0-9]\+\).*/\1/g')
        ;;
    Linux)
        LAPTOP_ID=$(xinput | grep "AT Translated Set 2 keyboard" | sed -e 's/.*id=\([0-9]\+\).*/\1/g')
        KIN_USB_ID=$(lsusb | grep -i "Kinesis Advantage Pro" | awk '{ print $6 }')
        ERG_USB_ID=$(lsusb | grep -i "feed:1307" | awk '{ print $6 }')
        SUN_USB_ID=$(lsusb | grep -i "Sun Microsystems, Inc. Type 6 Keyboard" | awk '{ print $6 }')
        ;;
    *)
        ;;
esac

echo "Setting up laptop"
setxkbmap ${LAPTOP_OPTIONS} -device ${LAPTOP_ID} -print > ${XKB_DIR}/keymap/icd.laptop
# xkbcomp -I${HOME}/.xkb -i ${LAPTOP_ID} -synch \
xkbcomp -I${HOME}/.xkb -synch \
    ${HOME}/.xkb/keymap/icd.laptop $DISPLAY # 2> /dev/null

if [ "x${KIN_USB_ID}" != "x" ]; then
    echo "Setting up Kinesis"
    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${XKB_DIR} \
            -device ${XID} \
            ${KIN_OPTIONS} \
            -print | sed -e 's@+ctrl(nocaps)@@g;s@bksp)@bksp)+lalt_meta(lalt_meta)@g' > ${HOME}/.xkb/keymap/icd.kin
        xkbcomp -I${HOME}/.xkb -i ${XID} -synch \
            ${HOME}/.xkb/keymap/icd.kin ${DISPLAY} # 2> /dev/null
    done
    xkbcomp -I${HOME}/.xkb -synch \
        ${HOME}/.xkb/keymap/icd.kin ${DISPLAY} # 2> /dev/null
    xmodmap -e "remove mod1 = Alt_R"
    xmodmap -e "add mod4 = Alt_R"
fi

if [ "x${SUN_USB_ID}" != "x" ]; then
    echo "Setting up Sun Type 6"
    SUN_XINPUT_ID=$(xinput | grep ${SUN_USB_ID} | sed -e 's/.*id=\([0-9]\+\).*/\1/g')
    echo "ID: ${SUN_XINPUT_ID}"
    for XID in $SUN_XINPUT_ID; do
        echo $XID
        setxkbmap \
            -I${XKB_DIR} \
            -device ${XID} \
            ${SUN_OPTIONS} \
            -print | sed -e '/xkb_keycodes/s/"[[:space:]]/+sunt6fix&/' > ${HOME}/.xkb/keymap/icd.sun
        xkbcomp -I${HOME}/.xkb -i ${XID} -synch \
            ${HOME}/.xkb/keymap/icd.sun ${DISPLAY} # 2> /dev/null
    done
fi

echo ${ERG_USB_ID}
if [ "x${ERG_USB_ID}" != "x" ]; then
    echo "Setting up ergodox"
    ERG_XINPUT_ID=$(xinput | grep "ErgoDox EZ" | grep keyboard | sed -e 's/.*id=\([0-9]\+\).*/\1/g')
    echo "ID: ${ERG_XINPUT_ID}"
    for XID in $ERG_XINPUT_ID; do
        echo $XID
        setxkbmap \
            -I${XKB_DIR} \
            -device ${XID} \
            ${ERG_OPTIONS} \
            -print > ${HOME}/.xkb/keymap/icd.erg
            # -print | sed -e 's@+group(shifts_toggle)@+ctrl(nocaps)&@g' > ${HOME}/.xkb/keymap/icd.erg
        # xkbcomp -I${HOME}/.xkb -i ${XID} -synch \
        xkbcomp -I${HOME}/.xkb -synch \
            ${HOME}/.xkb/keymap/icd.erg ${DISPLAY} # 2> /dev/null
    done
fi


echo icd > ${HOME}/.xmonad/layout