-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkdlaunch
executable file
·37 lines (27 loc) · 871 Bytes
/
kdlaunch
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
#! /bin/dash
XMODMAP_CONF="$HOME/.xmodmaprc"
KEYDOUBLE_CONF="$HOME/.keydoublerc"
die() {
printf "%s\n" "$@" >&2
exit 1
}
[ -f "$KEYDOUBLE_CONF" ] || die "found no configuration file\n"
natart_pairs=$(grep -i '^![[:space:]]*natart_pairs:' "$KEYDOUBLE_CONF" | sed 's/^[^:]\+:[[:space:]]*//')
[ -z "$natart_pairs" ] && die "please define a natart_pairs header\n"
restore_map() {
# If setxkbmap has no query option, change lyt to your local layout;
# e.g. "us", "fr", etc.
lyt=$(setxkbmap -query | grep -i '^layout:' | awk '{print $2}')
if [ -n "$lyt" ] ; then
setxkbmap -layout "$lyt"
else
die "couldn't guess the current keyboard layout"
fi
[ -f "$XMODMAP_CONF" ] && xmodmap "$XMODMAP_CONF"
exit 0
}
trap restore_map INT
xmodmap "$KEYDOUBLE_CONF"
# don't use quotes here
keydouble $natart_pairs
restore_map