• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

man/H02-Feb-2021-4544

src/H02-Feb-2021-661454

.gitignoreH A D02-Feb-202116 43

.vimrc_local.vimH A D02-Feb-202169 54

COPYINGH A D02-Feb-202134.3 KiB675553

README.mdH A D02-Feb-20213.7 KiB13095

default.nixH A D02-Feb-2021376 118

localrc.vimH A D02-Feb-2021240 119

test.shH A D02-Feb-20211.2 KiB6551

xkb-group.shH A D02-Feb-20211.7 KiB8168

README.md

1
2XKB-SWITCH
3===========
4by J. Bromley, S. Mironov, Alexei Rad'kov
5
6xkb-switch is a C++ program that allows to query and change the XKB layout state.
7Originally ruby-based code written by J.Broomley.
8
9* XKeyboard.cpp  Implementation for XKB query/set class
10* XKbSwitch.cpp  Main program
11* XKbSwitchApi.cpp The Vim API bindings
12
13The C++ class has no special dependencies on anything outside of
14X-related libraries, so it can be easily used with other software.
15
16Xkb-switch is licensed under the GNU GPLv3, see COPYING for details.
17
18Installing
19----------
20
21Package *libxkbfile-dev* (or *libxkbfile-devel* for Fedora) needs to be
22installed to build the program.
23
24To build the program manually, unpack the tarball and cd to source directory.
25[Nix](http://nixos.org/nix) users may use `nix-shell` to enter the minimally
26sufficient development shell or `nix-build` to build the sources. Other
27distributions typically require the following commands to build and install the
28program:
29
30```sh
31$ mkdir build && cd build
32$ cmake ..
33$ make
34```
35
36Optionally, test the basic functions by running `./test.sh` script. The script
37should print OK in the last line and return exit code of zero.
38
39```sh
40$ ../test.sh 2>&1 | tee test.log
41$ tail -n 1 test.log | grep OK || echo "Test failed!"
42```
43
44In order to install, use your system's package manager or default to the following:
45
46```sh
47$ sudo make install
48```
49
50On some distributions, you may need to update the program cache if it's the
51first time you're installing this program
52
53```sh
54$ sudo ldconfig
55```
56
57Usage
58-----
59
60```
61$ xkb-switch --help
62
63Usage: xkb-switch -s ARG            Sets current layout group to ARG
64       xkb-switch -l|--list         Displays all layout groups
65       xkb-switch -h|--help         Displays this message
66       xkb-switch -v|--version      Shows version number
67       xkb-switch -w|--wait [-p]    Waits for group change and exits
68       xkb-switch -W                Infinitely waits for group change
69       xkb-switch -n|--next         Switch to the next layout group
70       xkb-switch [-p]              Displays current layout group
71```
72
73*A note on `xkb-switch -x`*
74Command line option `xkb-switch -x` has been removed recently. Please, use `setxkbmap
75-query` or `setxkbmap -print` to obtain debug information.
76
77VIM integration
78---------------
79
80Xkb-switch goes with a library libxkbswitch.so which can be called from
81within Vim scripts like this:
82
83```vim
84let g:XkbSwitchLib = "/path/to/libxkbswitch.so"
85echo libcall(g:XkbSwitchLib, 'Xkb_Switch_getXkbLayout', '')
86call libcall(g:XkbSwitchLib, 'Xkb_Switch_setXkbLayout', 'us')
87```
88
89See also [article in Russian](http://lin-techdet.blogspot.ru/2012/12/vim-xkb-switch-libcall.html)
90describing complex solution.
91
92Layout groups
93-------------
94
95xkb-group.sh can help you to manage layout groups. Just run it and send some
96input at it's stdin every time you want to trigger layouts from primary to
97secondary and back. For example:
98
99```sh
100$ xkb-group.sh us ru
101switch # switch from us to ru or from current layout to us
102switch # switch from ru to us or from us to ru
103
104# from another terminal
105$ xkb-switch -s de # switch to 'de' layout, change secondary layout to 'de'
106
107# back to terminal running `xkb-group.sh'
108switch # switch from de to us
109switch # switch from us to de
110```
111
112Bugs or Problems
113----------------
114
115Admittedly, I only tested with a few different layouts that I used. If you find
116any bugs let me know by submitting an issue or via grrwlf@gmail.com.
117
118References:
119
120* <https://www.x.org/releases/X11R7.5/doc/input/XKB-Config.html>
121  - XKB configuration
122* <https://www.x.org/releases/current/doc/xorg-docs/input/XKB-Enhancing.html>
123  - How to further enhance XKB configuration
124* <https://0x64616c.livejournal.com/914.html>
125  - Old LJ post by Mitya describing minimalistic X11 kb test application
126
127Regards,
128Sergey.
129
130