aboutsummaryrefslogtreecommitdiff
path: root/users/ericgebhart/switch-kbd
diff options
context:
space:
mode:
Diffstat (limited to 'users/ericgebhart/switch-kbd')
-rwxr-xr-xusers/ericgebhart/switch-kbd74
1 files changed, 74 insertions, 0 deletions
diff --git a/users/ericgebhart/switch-kbd b/users/ericgebhart/switch-kbd
new file mode 100755
index 000000000..4401967a0
--- /dev/null
+++ b/users/ericgebhart/switch-kbd
@@ -0,0 +1,74 @@
1#!/usr/bin/env zsh
2
3# Switch the keyboard to en-us by default, bepo, or en-dvorak.
4
5help(){
6 print 'switch-kbd - helper for setxkbmap'
7 print ' '
8 print 'Change the keyboard to en-us, fr-bepo, or en-dvorak.'
9 print 'Uses setxkbmap, so the change only affects the current'
10 print 'session. This mainly to avoid using a toggle key.'
11 print ' '
12 print ' -b Bepo'
13 print ' -d Dvorak'
14 print ' -n do not execute'
15 print ' -h help text.'
16 print ' '
17 print ' The default is to set the keyboard to en-us.'
18 exit
19}
20
21layout="-layout us"
22variant=""
23let "execute = 1"
24let "verose = 0"
25
26# $opt will hold the current option
27local opt
28while getopts bdnvh opt; do
29 # loop continues till options finished
30 # see which pattern $opt matches...
31 case $opt in
32 (b)
33 layout="-layout fr"
34 variant="-variant bepo"
35 ;;
36
37 (d)
38 layout="-layout en"
39 variant="-variant dvorak"
40 ;;
41 (n)
42 let "execute = 0"
43 ;;
44 (v)
45 let "verbose = 1"
46 ;;
47 (h)
48 help
49 ;;
50 # matches a question mark
51 # (and nothing else, see text)
52 (\?)
53 print "Bad option:" $*
54 print " "
55 help
56 return 1
57 ;;
58 esac
59done
60(( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
61##print Remaining arguments are: $*
62
63mycommand='setxkbmap '${layout}' '${variant}
64
65if [[ ( $verbose -ne 0 ) ]]; then;
66 print "setxkbmap Command:" $mycommand
67fi
68
69if [[ ( $execute -ne 0 ) ]]
70then;
71 eval $mycommand
72else;
73 print "did not execute"
74fi