-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdkbswitch
More file actions
executable file
·31 lines (27 loc) · 964 Bytes
/
dkbswitch
File metadata and controls
executable file
·31 lines (27 loc) · 964 Bytes
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
#!/bin/sh
# This script is licensed under the Unlicense, see LICENSE for full details
# A simple keyboard switcher for X11 using dmenu
# Make a file called ~/.config/kblayouts, the syntax is the exact same as setxkbmap
HELP="Usage: dkbswitch [-hvcdf]
Simple keyboard switcher using dmenu
-h display help and exits
-v display version and exits
-c [location] change layouts location
-d [command] change dmenu command
-f [layout] change fallback layout"
VERSION="1.0"
while getopts ":vhc:d:f:" opt; do
case "$opt" in
"h") echo "$HELP"; exit 1;;
"v") echo "$VERSION"; exit 1;;
"c") kbfile="$OPTARG";;
"d") dmenucommand="$OPTARG";;
"f") default="$OPTARG";;
*) echo "$HELP"; exit 1;;
esac
done
[ -z "$default" ] && default="us"
[ -z "$dmenucommand" ] && dmenucommand="dmenu"
[ -z "$kbfile" ] && kbfile="$HOME/.config/kblayouts"
kb=$($dmenucommand < "$kbfile")
setxkbmap $kb || setxkbmap $default