Made setxkb ShortStr arg positional

This commit is contained in:
DreymaR 2017-10-29 16:33:50 +01:00
parent 829b47e2d8
commit eadcbdd9ad
4 changed files with 52 additions and 45 deletions

View File

@ -4,9 +4,9 @@ DreymaR's Big Bag of Keyboard Tricks
### For Linux (updated to XKB-data v2.17.1ub1, 2016-06) ### For Linux (updated to XKB-data v2.17.1ub1, 2016-06)
* New "Colemak[eD]" AltGr mappings (lv3-4) putting dead keys on AltGr+symbol keys and reworking most other mappings * New "Colemak[eD]" AltGr mappings (lv3-4) putting dead keys on AltGr+symbol keys and reworking most other mappings
* An "Extend" layer using Caps Lock as a modifier (lv5-8) for navigation/editing from the home position and more
* Angle/Wide ergo modifications to improve wrist angles, hand spacing and right pinky stretch/load effort * Angle/Wide ergo modifications to improve wrist angles, hand spacing and right pinky stretch/load effort
* Curl(DH) ergo modifications to encourage natural finger curvature * Curl(DH) ergo modifications to encourage natural finger curvature
* An "Extend" layer using Caps Lock as a modifier (lv5-8) for navigation/editing from the home position and more
* For several locales, a 'Unified Symbols' layout with only a few necessary changes from the standard Colemak[eD]; * For several locales, a 'Unified Symbols' layout with only a few necessary changes from the standard Colemak[eD];
Also, a layout to 'Keep Local Symbols' like their default (QWERTY-type) counterparts for that locale Also, a layout to 'Keep Local Symbols' like their default (QWERTY-type) counterparts for that locale
* Intuitive phonetic layouts for Cyrillic, Greek and Hebrew scripts * Intuitive phonetic layouts for Cyrillic, Greek and Hebrew scripts

View File

@ -8,20 +8,20 @@
HeadStr="DreymaR's Big Bag Of Tricks install script (by GadOE, 2016-06)" HeadStr="DreymaR's Big Bag Of Tricks install script (by GadOE, 2016-06)"
DescStr=\ DescStr=\
"\e[1mShell script to apply DreymaR's changes to the X keyboard files:\e[0m\n"\ "\e[1mShell script to apply DreymaR's changes to the X keyboard files:\e[0m\n"\
" - CurlAngleWide Ergonomic keyboard models for pc104/pc105 keyboards,\n"\ " - The Colemak [edition DreymaR] layout, using my own lv3-4 mappings,\n"\
" - Curl/Angle/Wide Ergonomic keyboard models for pc104/pc105 keyboards,\n"\
" - Extend mappings as a Misc option and CapsLock as a chooser (using lv5-8),\n"\ " - Extend mappings as a Misc option and CapsLock as a chooser (using lv5-8),\n"\
" - the Colemak [edition DreymaR] layout, using my own lv3-4 mappings,\n"\
" - locale variants of Colemak[eD] with 'keep local' or 'unified' symbol keys,\n"\ " - locale variants of Colemak[eD] with 'keep local' or 'unified' symbol keys,\n"\
" - phonetic variants of Colemak for other scripts such as Greek,\n"\ " - phonetic variants of Colemak for other scripts such as Greek,\n"\
" - mirrored Colemak[eD] for one-handed typing, (if I ever break an arm...)\n"\ " - mirrored Colemak[eD] for one-handed typing (if I ever break an arm...),\n"\
" - and the Tarmak(1-4) transitional (step-by-step) Colemak learning layouts.\n"\ " - and the Tarmak(1-4) transitional step-by-step Colemak learning layouts.\n"\
"\n"\ "\n"\
"- By default, this script creates a backup of the X11 files if none exist.\n"\ "- By default, this script creates a backup of the X11 files if none exist.\n"\
"- With '-o', overwrite the system X11 files (makes the mod GUI accessible).\n"\ "- With '-o', overwrite the system X11 files (makes the mod GUI accessible).\n"\
"- With '-s <mdl loc sym>', specify a model/layout to activate immediately.\n"\ "- With a ShortStr at the end, specify a model/layout to activate immediately.\n"\
" (Shortstr format: -s '[4|5][n|a|b|v][w|f] loc [ks|us]'; 'loc'(ale) is 2-letter.\n"\ " - ShortStr format: '[4|5][n|a|c][w|f] loc [ks|us]'; 'loc'(ale) is 2-letter.\n"\
" Some model shortstr examples: '4n' is pc104, '5aw' is pc105AngleWide etc.\n"\ " - E.g., '5n fr us' is normal pc105 model, French Cmk[eD]-'UniSym'.\n"\
" E.g.: -s '5n fr us' is normal pc105 model, French Colemak[eD]'USym'.)\n"\ " - See setxkb.sh help for more info on ShortStr syntax.\n"\
"- With '-?', list further instructions and default values.\n"\ "- With '-?', list further instructions and default values.\n"\
"- See http://forum.colemak.com/viewtopic.php?id=1438 for more info\n" "- See http://forum.colemak.com/viewtopic.php?id=1438 for more info\n"
# #
@ -67,10 +67,10 @@ DoBackup='ifnone' # (-n/b) Default backup behavior is "if no backups are found"
SubDirs='all' # (-m) Directory/-ies inside X11 to modify (e.g., 'xkb locale', 'all') SubDirs='all' # (-m) Directory/-ies inside X11 to modify (e.g., 'xkb locale', 'all')
InstGTK='no' # (-g) Whether to install the GTK 2.0/3.0 config (if not present) InstGTK='no' # (-g) Whether to install the GTK 2.0/3.0 config (if not present)
SetXMap='no' # (-x) Whether to run the setxkb script after installing SetXMap='no' # (-x) Whether to run the setxkb script after installing
SetXStr='5cw us us' # (-s) Shortcut string for setxkb - 'mmm ll vv' (model layout eD-variant) SetXStr='5cw us us' # (--) Shortcut string for setxkb - 'kbd loc sym' (model layout eD-variant)
## NOTE: '# (-a)' means that the value can be set by option argument '-a <value>' ## NOTE: '# (-a)' means that the value can be set by option argument '-a <value>'
HelpStr="\e[1mUsage: bash ${MyNAME} [optional args]\e[0m\n"\ HelpStr="\e[1mUsage: bash ${MyNAME} [optional args] [<kbd> [<loc> <sym>]]\e[0m\n"\
" Run this from the directory containing the x-mod dir\n"\ " Run this from the directory containing the x-mod dir\n"\
"===========================================================\n"\ "===========================================================\n"\
"[-#] Functionality - 'default' \n"\ "[-#] Functionality - 'default' \n"\
@ -83,10 +83,9 @@ HelpStr="\e[1mUsage: bash ${MyNAME} [optional args]\e[0m\n"\
"[-d] <mod dir path> - ${DModDir}\n"\ "[-d] <mod dir path> - ${DModDir}\n"\
"[-m] <X11 subdir(s) to mod> - ${SubDirs}\n"\ "[-m] <X11 subdir(s) to mod> - ${SubDirs}\n"\
"[-t] <mod dir prefix tag> - ${DModTag}\n"\ "[-t] <mod dir prefix tag> - ${DModTag}\n"\
"[-g] Install GTK 2.0/3.0 edit config - ${InstGTK}\n"\ "[-g] Install GTK 2.0/3.0 edit config? - ${InstGTK}\n"\
"[-x] Run the setxkbmap script, yes/no - ${SetXMap}\n"\ "[-x] Run the setxkbmap script? - ${SetXMap}\n"\
"[-s] Setxkb ShortStr 'mdl loc sym' - ${SetXStr}\n"\ "[--] [Setxkb ShortStr <kbd loc sym>] - ${SetXStr}\n"
" (See setxkb help for more info on ShortStr)\n"
#~ "( - <val> : Default settings)\n" #~ "( - <val> : Default settings)\n"
##-------------- functions and line parser --------------------- ##-------------- functions and line parser ---------------------
@ -139,15 +138,13 @@ MyError()
#~ } #~ }
#~ if [ "$#" == 0 ]; then PrintHelpAndExit 2; fi # No args #~ if [ "$#" == 0 ]; then PrintHelpAndExit 2; fi # No args
while getopts "obngxs:m:i:d:t:r:h?" cmdarg; do while getopts "obngxm:i:d:t:r:h?" cmdarg; do
case $cmdarg in case $cmdarg in
o) WriteSys='yes' ;; o) WriteSys='yes' ;;
b) DoBackup='yes' ;; b) DoBackup='yes' ;;
n) DoBackup='no' ;; n) DoBackup='no' ;;
g) InstGTK='yes' ;; g) InstGTK='yes' ;;
x) SetXMap='yes' ;; x) SetXMap='yes' ;;
s) SetXStr="$OPTARG"
SetXMap='yes' ;;
m) SubDirs="$OPTARG" ;; m) SubDirs="$OPTARG" ;;
i) InstDir="$OPTARG" ;; i) InstDir="$OPTARG" ;;
d) DModDir="$OPTARG" ;; d) DModDir="$OPTARG" ;;
@ -156,9 +153,13 @@ while getopts "obngxs:m:i:d:t:r:h?" cmdarg; do
h) PrintHelpAndExit 0 ;; h) PrintHelpAndExit 0 ;;
\?) PrintHelpAndExit 0 ;; \?) PrintHelpAndExit 0 ;;
:) PrintHelpAndExit 1 ;; :) PrintHelpAndExit 1 ;;
# s) SetXStr="$OPTARG"
# SetXMap='yes' ;;
esac esac
done done
#~ pos_arg=${@:$OPTIND:1} # Get the remaining (positional) arg #~ pos_arg=${@:$OPTIND:1} # Get the remaining positional arg (old way)
shift $(( $OPTIND - 1 )) # Remove already processed args
[[ "$@" == "" ]] || SetXStr=$@ # Don't split the ShortString here!
##-------------- main ------------------------------------------ ##-------------- main ------------------------------------------
@ -257,7 +258,7 @@ fi
if [ "${SetXMap}" != 'yes' ]; then if [ "${SetXMap}" != 'yes' ]; then
MyMsg "XKBmap activation skipped" "" '1;33;40' MyMsg "XKBmap activation skipped" "" '1;33;40'
else else
bash ./setxkb.sh -d "${XKBDir}" -s "${SetXStr}" || MyError "setxkb.sh failed!" bash ./setxkb.sh -d "${XKBDir}" ${SetXStr} || MyError "setxkb.sh failed!"
fi fi
MyMsg "${MyNAME} finished!" "\n" MyMsg "${MyNAME} finished!" "\n"
@ -265,5 +266,5 @@ exit 0
##-------------- misc ------------------------------------------ ##-------------- misc ------------------------------------------
#~ MyError "Debug - run halted!" # debug #~ MyWarning "'${MyNAME}' debug - exiting!"; exit 0
#~ echo "$1 $2 $3 $4 $5"; exit 0 # debug #~ echo "$1 $2 $3 $4 $5"; exit 0 # debug

View File

@ -9,7 +9,7 @@ HeadStr="DreymaR's setxkbmap script (by GadOE, 2015-01)"
DescStr=\ DescStr=\
"\e[1mShell script to change X.org keyboard setup\e[0m\n"\ "\e[1mShell script to change X.org keyboard setup\e[0m\n"\
" using the 'setxkbmap' command.\n"\ " using the 'setxkbmap' command.\n"\
" To override system settings after logon,\n"\ " To make settings logon persistent,\n"\
" source it, e.g., in your ~/.bashrc file,\n"\ " source it, e.g., in your ~/.bashrc file,\n"\
" or use -a to write the setxkbmap command to a file.\n" " or use -a to write the setxkbmap command to a file.\n"
FootStr="Happy xkb-hacking! ~ Øystein Bech 'DreymaR' Gadmar" FootStr="Happy xkb-hacking! ~ Øystein Bech 'DreymaR' Gadmar"
@ -18,9 +18,9 @@ FootStr="Happy xkb-hacking! ~ Øystein Bech 'DreymaR' Gadmar"
# By default, setxkbmap checks ./rules first! # By default, setxkbmap checks ./rules first!
# Need a full xkb dir then (not just the xkb-mod files) # Need a full xkb dir then (not just the xkb-mod files)
## NOTE: I made a handy shorthand for activating simple cmk_ed model/layout combos. ## NOTE: I made a handy shorthand for activating simple Cmk[eD] model/layout combos.
# See the help text of this script for more info on the model-layout-variant syntax. # See the help text of this script for more info on the model-locale-symbols syntax.
# Example: -s '5w no us' activates model pc105aw-sl, layout no(cmk_ed_us) # Example: '5w no us' activates model pc105aw-sl, layout no(cmk_ed_us)
# Models: 4n 4a(pc104angle-z) 4w(pc104wide-qu) 4aw(pc104aw-zqu) 4f(pc104awing) # Models: 4n 4a(pc104angle-z) 4w(pc104wide-qu) 4aw(pc104aw-zqu) 4f(pc104awing)
# 5n 5a(pc105angle) 5w/5aw(pc105aw-sl) # 5n 5a(pc105angle) 5w/5aw(pc105aw-sl)
# - Curl(DH) models add a 'c', like this: 4c, 5cw etc # - Curl(DH) models add a 'c', like this: 4c, 5cw etc
@ -47,32 +47,33 @@ XKBdir="${X11DIR}/xkb" # (-d) The xkb-type dir to run setxkbmap from
AddCmd='no' # (-a) Add setxkbmap cmd to file? AddCmd='no' # (-a) Add setxkbmap cmd to file?
AddDefault="${HOME}/.bashrc" AddDefault="${HOME}/.bashrc"
AddCmdTo=${AddDefault} # (-f) File (such as '~/.bashrc') to add setxkbmap cmd to AddCmdTo=${AddDefault} # (-f) File (such as '~/.bashrc') to add setxkbmap cmd to
SetXStr='' #'5cw no us' # (-s) Shortcut string for setxkb - 'model locale eD-variant(sym)' SetXStr='' #'5cw no us' # (--) Shortcut string for setxkb (model locale eD-variant)
## NOTE: '# (-a)' means that the value can be set by option argument '-a <value>' ## NOTE: '# (-a)' means that the value can be set by option argument '-a <value>'
HelpStr="\e[1mUsage: bash ${MyNAME} [optional args]\e[0m\n"\ HelpStr="\e[1mUsage: bash ${MyNAME} [optional args] [<kbd> [<loc> <sym>]]\e[0m\n"\
"===========================================================\n"\ "===========================================================\n"\
"[-#] Functionality - 'default' \n"\ "[-#] Functionality - 'default' \n"\
"===========================================================\n"\ "===========================================================\n"\
"[-m] <model> - '${XKBmodel}'\n"\ "[-m] <model> - '${XKBmodel}'\n"\
"[-l] <layout> - '${XKBlayout}'\n"\ "[-l] <layout(variant)> - '${XKBlayout}'\n"\
"[-o] <option> - \n"\ "[-o] <options> - \n"\
" '${XKBoption}'\n"\ " '${XKBoption}'\n"\
"[-v] <verbose level> - '${VerboseLvl}'\n"\ "[-v] <verbose level> - '${VerboseLvl}'\n"\
"[-s] <ShortStr> 'mod lay sym' - '${SetXStr}'\n"\
"[-d] Run from <directory> - '${XKBdir}'\n"\ "[-d] Run from <directory> - '${XKBdir}'\n"\
"[-k] Keep old XKB server(s) - '${KeepXKM}'\n"\ "[-k] Keep old XKB server(s) - '${KeepXKM}'\n"\
"[-a] Add cmd line to file? - '${AddCmd}'\n"\ "[-a] Add cmd line to file? - '${AddCmd}'\n"\
"[-f] <file> to add cmd to - '${AddCmdTo}'\n"\ "[-f] <file> to add cmd to - '${AddCmdTo}'\n"\
"\n\e[1mShortStr notation (a space separated string defining model+layout):\e[0m\n"\ "[--] <ShortStr> - '${SetXStr}'\n"\
" 1) 4/5 - ANSI-104/ISO-105 keyboard,\n"\ "\n\e[1mShortStr syntax, defining eD model+layout as a short split string:\e[0m\n"\
" n/a/c - Normal/Angle/Curl-DH\n"\ "==================================================================\n"\
" w/f - Wide/A-Wing (a.k.a. 'A-Frame')\n"\ " <kbd> 4/5 - ANSI-104/ISO-105 keyboard model, then...\n"\
" 2) Two-letter layout code like 'us' for USA, 'gb' for UK etc\n"\ " n/a/c - Normal/Angle/Curl-DH, and optionally...\n"\
" 3) 'us'/'ks' for 'Universal'/'Keep Local' symbol locale variants\n"\ " w/f - Wide/A-Wing (a.k.a. 'A-Frame')\n"\
" Examples: '5a se us': PC105-Angle, Swedish Cmk[eD] 'UniSym'\n"\ " <loc> Two-letter locale layout code like 'us' for USA, 'gb' for UK etc\n"\
" <sym> 'us'/'ks' for 'Universal' or 'Keep Locale' symbol variants\n\n"\
" Examples: '5a se us': PC105-Angle, Swedish Cmk[eD] 'UnifiedSym'\n"\
" '4cf gb ks': PC104-Curl(DH)AWing, Eng.(UK) Cmk[eD] 'KeepSym'\n"\ " '4cf gb ks': PC104-Curl(DH)AWing, Eng.(UK) Cmk[eD] 'KeepSym'\n"\
" '5cw': PC105-Curl(DH)AngleWide - keep current layout/variant\n" " '5cw': PC105-Curl(DH)AngleWide, keep current layout/variant\n"
#~ " (See the script's comments for more info.)" #~ " (See the script's comments for more info.)"
@ -126,13 +127,12 @@ MyCD()
} }
#~ if [ "$#" == 0 ]; then PrintHelpAndExit 2; fi # No args #~ if [ "$#" == 0 ]; then PrintHelpAndExit 2; fi # No args
while getopts "m:l:o:v:s:d:f:akh?" cmdarg; do while getopts "m:l:o:v:d:f:akh?" cmdarg; do
case $cmdarg in case $cmdarg in
m) XKBmodel="$OPTARG" ;; m) XKBmodel="$OPTARG" ;;
l) XKBlayout="$OPTARG" ;; l) XKBlayout="$OPTARG" ;;
o) XKBoption="$OPTARG" ;; o) XKBoption="$OPTARG" ;;
v) VerboseLvl="$OPTARG" ;; v) VerboseLvl="$OPTARG" ;;
s) SetXStr=($OPTARG) ;; # Split the string
d) XKBdir="$OPTARG" ;; d) XKBdir="$OPTARG" ;;
f) AddCmdTo="$OPTARG" ;; f) AddCmdTo="$OPTARG" ;;
a) AddCmd='yes' ;; a) AddCmd='yes' ;;
@ -140,11 +140,13 @@ while getopts "m:l:o:v:s:d:f:akh?" cmdarg; do
h) PrintHelpAndExit 0 ;; h) PrintHelpAndExit 0 ;;
\?) PrintHelpAndExit 0 ;; \?) PrintHelpAndExit 0 ;;
:) PrintHelpAndExit 1 ;; :) PrintHelpAndExit 1 ;;
# s) SetXStr=($OPTARG) ;; # Split the string
esac esac
done done
#~ pos_arg=${@:$OPTIND:1} # Get the remaining (positional) arg shift $(( $OPTIND - 1 )) # Remove already processed args
[[ "$@" == "" ]] || SetXStr=($@) # Split the ShortString
if [ -n "${SetXStr}" ]; then # Use the ShortStr notation if [ -n "${SetXStr}" ]; then # Use ShortString notation
case ${SetXStr[0]} in case ${SetXStr[0]} in
4n) XKBmodel='pc104' ;; # Generic ANSI-101/104-key 4n) XKBmodel='pc104' ;; # Generic ANSI-101/104-key
4a) XKBmodel='pc104angle-z' ;; # w/ Angle(Z) ergo mod 4a) XKBmodel='pc104angle-z' ;; # w/ Angle(Z) ergo mod
@ -176,7 +178,7 @@ case ${XKBmodel} in
pc105curl) Curling='yes' ;; # PC105-Curl(DH)Angle(LSGT) pc105curl) Curling='yes' ;; # PC105-Curl(DH)Angle(LSGT)
pc105caw-sl) Curling='yes' ;; # PC105-Curl(DH)AngleWide(Slash) pc105caw-sl) Curling='yes' ;; # PC105-Curl(DH)AngleWide(Slash)
esac esac
[ $Curling == 'yes' ] && XKBoption+=',misc:cmk_curl_dh' [[ $Curling == 'yes' ]] && XKBoption+=',misc:cmk_curl_dh'
##-------------- main ------------------------------------------ ##-------------- main ------------------------------------------
@ -186,6 +188,7 @@ MyMsg "$HeadStr"
if [ -n "${SetXStr}" ]; then if [ -n "${SetXStr}" ]; then
MyPoint "Using model/layout '$XKBmodel'/'$XKBlayout' from ShortStr" MyPoint "Using model/layout '$XKBmodel'/'$XKBlayout' from ShortStr"
fi fi
MyCD "${XKBdir%/}" MyCD "${XKBdir%/}"
#~ MyPoint "Running from `pwd`" #~ MyPoint "Running from `pwd`"
@ -237,6 +240,7 @@ exit 0
##-------------- misc ------------------------------------------ ##-------------- misc ------------------------------------------
#~ MyWarning "'${MyNAME}' debug - exiting!"; exit 0
#~ echo "'$XKBmodel' '$XKBlayout'"; for i in 0 1 2; do echo "'${SetXStr[i]}'"; done; exit 0 #~ echo "'$XKBmodel' '$XKBlayout'"; for i in 0 1 2; do echo "'${SetXStr[i]}'"; done; exit 0
## US/ANSI Wide ergo mod, ## US/ANSI Wide ergo mod,

View File

@ -151,6 +151,8 @@ xkb_symbols "cmk_ed_letters" {
key <AB07> { [ m, M, multiply, downarrow ] }; // QWE/Cmk M key <AB07> { [ m, M, multiply, downarrow ] }; // QWE/Cmk M
// U0292/01B7 ezh/EZH // U0292/01B7 ezh/EZH
//// Activating the line below will "hard" enable the Curl(DH) mod; see below.
// include "colemak(cmk_ed_dh)"
//// Activating the line below will "hard" enable the old Curl(DHm) mod; see below. //// Activating the line below will "hard" enable the old Curl(DHm) mod; see below.
// include "colemak(cmk_ed_dhm)" // include "colemak(cmk_ed_dhm)"
//// This is the old Curl(DvH) Colemak ergo mod, keeping V and M in place. //// This is the old Curl(DvH) Colemak ergo mod, keeping V and M in place.