From 0bba4a0eb3e813e43e327c87cb42d15750811c8c Mon Sep 17 00:00:00 2001 From: Kevin Mok Date: Wed, 14 Mar 2018 06:46:59 -0400 Subject: [PATCH] Swap keys using xkb instead of xmodmap Removed old swap key lines from config and added dir/script to symlink xkb file to lc dir. Fixes issue of having to release keys when starting terminal with xmodmap. --- aliases/zsh_aliases | 15 ++----- configs/set-config-dirs.sh | 11 ----- configs/set-configs.sh | 13 +++--- dotfiles/Xresources | 3 +- dotfiles/vimrc | 1 + dotfiles/zshrc | 23 ++++------ xkb/NZXT-pc | 87 ++++++++++++++++++++++++++++++++++++++ xkb/set-layouts.sh | 11 +++++ 8 files changed, 120 insertions(+), 44 deletions(-) delete mode 100755 configs/set-config-dirs.sh create mode 100644 xkb/NZXT-pc create mode 100755 xkb/set-layouts.sh diff --git a/aliases/zsh_aliases b/aliases/zsh_aliases index 2e9f44c..05d7c6c 100644 --- a/aliases/zsh_aliases +++ b/aliases/zsh_aliases @@ -168,7 +168,7 @@ if [ "$(hostname)" = "NZXT" ]; then alias sfa="f ~/Documents/self-authoring" alias rcg="$cd_coding_dir/random-color-generator" alias dcr="$cd_coding_dir/dcr-logger" - alias pf="$cd_coding_dir/ParsaFood" + alias prf="$cd_coding_dir/ParsaFood" # swbot {{{ # alias sb="$cd_coding_dir/swbot" @@ -204,14 +204,6 @@ fi # laptop {{{ if [[ "$(hostname)" = "X1-Carbon" ]]; then - # key swaps {{{ # - xmodmap -e "keycode 9 = Escape" - xmodmap -e "keycode 22 = Home" - xmodmap -e "keycode 119 = End" - xmodmap -e "keycode 110 = Delete" - xmodmap -e "keycode 115 = BackSpace" - # }}} key swaps # - alias gbl="xbacklight -get" function bl() { xbacklight -set $(echo "scale=2;$1*10" | bc) ; } @@ -258,7 +250,7 @@ alias gcam="git commit --amend" # todo: fix function gcm(){ echo git commit -m \""$1"\" ; } -function gpsg() { +function psg() { git add . git commit -m '.' git push @@ -329,7 +321,7 @@ alias cdn="$cd_coding_dir" ideas_dir="$coding_dir""/ideas" alias ids="f $ideas_dir" alias lci="f $ideas_dir/general" -alias vli="ni $ideas_dir/ideas.md" +alias vli="ni $ideas_dir/general/ideas.md" alias fyn="f $ideas_dir/yes-no" alias ans="f /usr/local/android-studio/bin && ./studio.sh" @@ -417,6 +409,7 @@ function run() { # temp {{{ # alias m8="make checkpasswd && ./checkpasswd < passwd.in" alias m3="make pfact && ./pfact.out 14" +function pf() { make pfact && ./pfact.out $1 ; } alias 35w="c9 3-5_wait.c && ./3-5_wait.out abc a" # }}} temp # diff --git a/configs/set-config-dirs.sh b/configs/set-config-dirs.sh deleted file mode 100755 index 27de17e..0000000 --- a/configs/set-config-dirs.sh +++ /dev/null @@ -1,11 +0,0 @@ -# Get directory variables from script. -. ../dirs.sh -# List of config dirs in system config dir that I want to link to. -# config_dirs=(neofetch i3 i3blocks sam-i3blocks ranger) -config_dirs=(neofetch i3 i3blocks ranger) -for cur_dir in $config_dirs; do - # Remove system file. - rm -rf "$sys_config_dir"/"$cur_dir" - # Link config file in repository to system config location. - ln -s "$config_dir"/"$pc"/"$cur_dir" "$sys_config_dir"/"$cur_dir" -done diff --git a/configs/set-configs.sh b/configs/set-configs.sh index aae4819..27de17e 100755 --- a/configs/set-configs.sh +++ b/configs/set-configs.sh @@ -1,12 +1,11 @@ # Get directory variables from script. . ../dirs.sh -# List of config files in system config dir that I want to link to. -config_files="neofetch/config.conf i3/config i3blocks/i3blocks.conf "\ -"sam-i3blocks/sam-i3blocks.conf" -for file in $config_files; do +# List of config dirs in system config dir that I want to link to. +# config_dirs=(neofetch i3 i3blocks sam-i3blocks ranger) +config_dirs=(neofetch i3 i3blocks ranger) +for cur_dir in $config_dirs; do # Remove system file. - rm "$sys_config_dir"/"$file" + rm -rf "$sys_config_dir"/"$cur_dir" # Link config file in repository to system config location. - ln -s "$config_dir"/"$pc"/$(echo "$file" | cut -d'/' -f 1).conf \ - "$sys_config_dir"/"$file" + ln -s "$config_dir"/"$pc"/"$cur_dir" "$sys_config_dir"/"$cur_dir" done diff --git a/dotfiles/Xresources b/dotfiles/Xresources index e0849fc..b9715bd 100644 --- a/dotfiles/Xresources +++ b/dotfiles/Xresources @@ -1,4 +1,5 @@ -URxvt.font: xft:hack:size=14 +! URxvt.font: xft:hack:size=14 +URxvt.font: xft:hack:size=13 /* transparency {{{ */ URxvt*inheritPixmap: true diff --git a/dotfiles/vimrc b/dotfiles/vimrc index 177ccd1..4ecb5f7 100644 --- a/dotfiles/vimrc +++ b/dotfiles/vimrc @@ -144,6 +144,7 @@ let mapleader="\" nnoremap cmt :%s/>\(.*\)>//g " delete line into system clipboard nnoremap D "+dd +nnoremap DA "+ggdG " reload file nnoremap e :e " reload folds diff --git a/dotfiles/zshrc b/dotfiles/zshrc index f89fad8..3c46dc6 100644 --- a/dotfiles/zshrc +++ b/dotfiles/zshrc @@ -94,18 +94,13 @@ source ~/linux-config/aliases/zsh_aliases # alias zshconfig="mate ~/.zshrc" # alias ohmyzsh="mate ~/.oh-my-zsh" -if [ "$(whoami)" = "kevin" ]; then - export PATH="${PATH}:${HOME}/.local/bin/" - (cat ~/.cache/wal/sequences &) - # keyboard delay/rate - xset r rate 200 60 -fi -# NZXT -if [ "$(hostname)" = "NZXT" ]; -then - xmodmap -e "clear Lock" - xmodmap -e "keycode 22 = Caps_Lock" - xmodmap -e "keycode 66 = BackSpace" -# else - # xrandr --dpi 150 +# pywal +export PATH="${PATH}:${HOME}/.local/bin/" +(cat ~/.cache/wal/sequences &) + +# keyboard delay/rate +xset r rate 200 60 +# laptop +if [ "$(hostname)" = "X1-Carbon" ]; + xrandr --dpi 125 fi diff --git a/xkb/NZXT-pc b/xkb/NZXT-pc new file mode 100644 index 0000000..5514f76 --- /dev/null +++ b/xkb/NZXT-pc @@ -0,0 +1,87 @@ +default partial alphanumeric_keys modifier_keys +xkb_symbols "pc105" { + + key { [ Escape ] }; + + // The extra key on many European keyboards: + key { [ less, greater, bar, brokenbar ] }; + + // The following keys are common to all layouts. + key { [ backslash, bar ] }; + key { [ space ] }; + + include "srvr_ctrl(fkey2vt)" + include "pc(editing)" + include "keypad(x11)" + + key { [ Caps_Lock ] }; + + key { [ Tab, ISO_Left_Tab ] }; + key { [ Return ] }; + + key { [ BackSpace, BackSpace ] }; + key { [ Num_Lock ] }; + + key { [ Shift_L ] }; + key { [ Control_L ] }; + key { [ Super_L ] }; + + key { [ Shift_R ] }; + key { [ Control_R ] }; + key { [ Super_R ] }; + key { [ Menu ] }; + + // Beginning of modifier mappings. + modifier_map Shift { Shift_L, Shift_R }; + modifier_map Lock { Caps_Lock }; + modifier_map Control{ Control_L, Control_R }; + modifier_map Mod2 { Num_Lock }; + modifier_map Mod4 { Super_L, Super_R }; + + // Fake keys for virtual<->real modifiers mapping: + key { [ ISO_Level3_Shift ] }; + key { [ Mode_switch ] }; + modifier_map Mod5 { , }; + + key { [ NoSymbol, Alt_L ] }; + include "altwin(meta_alt)" + + key { [ NoSymbol, Meta_L ] }; + modifier_map Mod1 { }; + + key { [ NoSymbol, Super_L ] }; + modifier_map Mod4 { }; + + key { [ NoSymbol, Hyper_L ] }; + modifier_map Mod4 { }; + // End of modifier mappings. + + key { [ XF86Display ] }; + key { [ XF86KbdLightOnOff ] }; + key { [ XF86KbdBrightnessDown ] }; + key { [ XF86KbdBrightnessUp ] }; +}; + +hidden partial alphanumeric_keys +xkb_symbols "editing" { + key { + type= "PC_ALT_LEVEL2", + symbols[Group1]= [ Print, Sys_Req ] + }; + key { [ Scroll_Lock ] }; + key { + type= "PC_CONTROL_LEVEL2", + symbols[Group1]= [ Pause, Break ] + }; + key { [ Insert ] }; + key { [ Home ] }; + key { [ Prior ] }; + key { [ Delete ] }; + key { [ End ] }; + key { [ Next ] }; + + key { [ Up ] }; + key { [ Left ] }; + key { [ Down ] }; + key { [ Right ] }; +}; diff --git a/xkb/set-layouts.sh b/xkb/set-layouts.sh new file mode 100755 index 0000000..a18fbbe --- /dev/null +++ b/xkb/set-layouts.sh @@ -0,0 +1,11 @@ +# Get directory variables from script. +. ../dirs.sh + +xkb_config_file_name="pc" +sys_layout_file="/usr/share/X11/xkb/symbols/$xkb_config_file_name" +xkb_config_dir="$linux_config_dir/xkb" + +# Remove system file. +sudo rm -rf "$sys_layout_file" +# Link config file in repository to system config location. +sudo ln -s "$xkb_config_dir"/"$pc"-"$xkb_config_file_name" "$sys_layout_file"