Paste2 Logo
  1. #!/bin/bash
  2.  
  3. # By Steven (http://stebalien.com)
  4. ########################################################################
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17. ########################################################################
  18.  
  19. case "$1" in
  20.         init)
  21.                 xmodmap -e 'clear Lock'
  22.                 xmodmap -e 'keycode 66 = F13'
  23.                 ;;
  24.         navigation)
  25.                 echo "Navigation Mode Set"
  26.                 xmodmap -e 'keycode 46 = Right'
  27.                 xmodmap -e 'keycode 45 = Up'
  28.                 xmodmap -e 'keycode 44 = Down'
  29.                 xmodmap -e 'keycode 43 = Left'
  30.                 ;;
  31.         normal)
  32.                 echo "Normal Mode Set"
  33.                 xmodmap -e 'keycode 46 = L'
  34.                 xmodmap -e 'keycode 45 = K'
  35.                 xmodmap -e 'keycode 44 = J'
  36.                 xmodmap -e 'keycode 43 = H'
  37.                 ;;
  38.         toggle)
  39.                 if xmodmap -pk|awk '{ print $1 " " $3 }' | grep '^45 '| grep 'K'; then
  40.                         echo "Navigation Mode Auto Set"
  41.                         xmodmap -e 'keycode 46 = Right'
  42.                         xmodmap -e 'keycode 45 = Up'
  43.                         xmodmap -e 'keycode 44 = Down'
  44.                         xmodmap -e 'keycode 43 = Left'
  45.                 else
  46.                         echo "Normal Mode Auto Set"
  47.                         xmodmap -e 'keycode 46 = L'
  48.                         xmodmap -e 'keycode 45 = K'
  49.                         xmodmap -e 'keycode 44 = J'
  50.                         xmodmap -e 'keycode 43 = H'
  51.                 fi
  52. esac
  53. exit 0
  54.