-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkbdlayout
executable file
·37 lines (32 loc) · 900 Bytes
/
kbdlayout
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/bash
source ~/.panelrc
_get_cur_layout() {
setxkbmap_out=$(setxkbmap -query)
regex='layout: +(..)'
if [[ "$setxkbmap_out" =~ $regex ]]; then
current_layout=${BASH_REMATCH[1]}
echo "$current_layout"
fi
}
_fifo_output() {
if [[ -p $PANEL_FIFO ]]; then
echo "${KBD_LAYOUT_PREFIX}$1" > $PANEL_FIFO
fi
}
if [[ "$1" == "get" ]]; then
_fifo_output "$(_get_cur_layout)"
else
# If the current layout is 'es', change to 'us', and viceversa,
# load the Xmodmap configuration and output it to bspwm's panel FIFO
case $(_get_cur_layout) in
es) setxkbmap us
xmodmap ~/.Xmodmaprc
xmodmap -e 'keysym Alt_R = Hangul'
_fifo_output "$(_get_cur_layout)"
;;
us) setxkbmap es
xmodmap ~/.Xmodmaprc
_fifo_output "$(_get_cur_layout)"
;;
esac
fi