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