Toggle keyboard layout

From Krayon, 3 Years ago, written in Bash, viewed 170 times.
URL https://p.qdnx.org/view/5652733b Embed
Download Paste or View Raw
  1. #!/bin/bash
  2.  
  3. function dv() {
  4.     setxkbmap dvorak
  5.     xmodmap "${HOME}/.xmodmaprc"
  6. }
  7.  
  8. function qw() {
  9.     setxkbmap us
  10.     xmodmap "${HOME}/.xmodmaprc"
  11. }
  12.  
  13. [ "${1}" == "-d" ] && dv && exit 0
  14. [ "${1}" == "-q" ] && qw && exit 0
  15.  
  16. # Assume toggle
  17.  
  18. cur="$(setxkbmap -query|grep layout:|awk '{print $2}')"
  19. echo "${cur}"
  20.  
  21. [ "${cur}" == "dvorak" ] && qw && exit 0
  22. [ "${cur}" == "us"     ] && dv && exit 0
  23.  
  24. # vim:ts=4:tw=80:sw=4:et:ai:si

Reply to "Toggle keyboard layout"

Here you can reply to the paste above