grwlf / xkb-switch Goto Github PK
View Code? Open in Web Editor NEWSwitch your X keyboard layouts from the command line
License: MIT License
Switch your X keyboard layouts from the command line
License: MIT License
It seems that this tool uses the word "group" to refer to what xkb calls "layout", which are complete keybard mapping. Here's the—admittedly confusing—definition of a group from the XKB Configuration Guide (emphasis mine):
You can use multi-layouts xkb configuration. What does it mean? Basically it allows to load up to four different keyboard layouts at a time. Each such layout would reside in its own group. The groups (unlike complete keyboard remapping) can be switched very fast from one to another by a combination of keys.
It would be very interesting if this tool could also change groups, as xkb's group-changing mechanism is somewhat limited (it requires you to reserve a key for only this purpose) and doesn't seem to be accessible from setxkbmap
. If this isn't an option, then maybe the docs could adopt the xkb terminology ("layout").
Hey!
I recently upgraded from version 20150826-3
to version 20150826-4
of xkb-switch via the Arch User Repository (the xkb-switch-git
package), and some behaviour has changed in an unexpected way. In particular, xkb-switch doesn't seem to output the keyboard layout variant anymore.
Before the update, calling xkb-switch
with no arguments would output us
or us(intl)
depending on which layout I was using. Now, xkb-switch
outputs just us
regardless of what layout I'm actually using at the moment. I just want to use xkb-switch to tell me the current layout variant, I don't actually use it to change the layout.
For reference, here is my xorg keyboard configuration:
Section "InputClass"
Identifier "system-keyboard"
MatchIsKeyboard "on"
Option "XkbLayout" "us,us"
Option "XkbVariant" ",intl"
Option "XkbOptions" "ctrl:nocaps, grp:alt_shift_toggle"
EndSection
Is there any way of getting xkb-switch to output the current layout variant again?
Thanks in advance for the help!
I have found xkb-switch package in ppa:atareao/atareao repository, but 1.4.0 version only.
Is it possible to put a new version there?
https://launchpad.net/~atareao/+archive/ubuntu/atareao?field.series_filter=xenial
I have some question to the usage
Firstly I set my keyboard layouts through setxkbmap
setxkbmap -layout 'us,de,bg' -variant ' , ,phonetic'
setxkbmap -option 'grp:alt_caps_toggle'
Than I call
xkb-switch -s "de( )"
and I can write switch
and I can switch between us
and bg
. When I want, I can quickly call xkb-switch -s "de( )"
and get it. This is clear.
Is it possible to bind some script to a key, so I can can switch between en
and bg
without opening a terminal? It there a better way, than running the xkb-group.sh
, finding it's pid and writing to stdin?
Ref #30
Add support for GNU gettext library and localize error messages.
It would be nice if there is an option to print the layouts in uppercase, as it looks better on some panels and status bars.
I made a modification of longwait function which transforms the string characters to uppercase.
if(m_lwait_u) {
while(true) {
xkb.wait_event();
xkb.build_layout(syms);
syms_collected = true;
string su = syms.at(xkb.get_group());
transform(su.begin(), su.end(), su.begin(), ::toupper);
cout << su << endl;
}
}
./xkb-switch -l
us
Why does it not list all available layouts on my stem like de, fr, en .... ?
uname -a Linux t-MS-7C90 5.15.0-58-generic #64-Ubuntu SMP Thu Jan 5 11:43:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
After
xkbcomp -I"$XDG_CONFIG_HOME/xkb" "$XDG_CONFIG_HOME/xkb/map" "$DISPLAY"
with"$XDG_CONFIG_HOME/xkb/map"
reading, say
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_symbols { include "pc+us(intl):1+ru(phonetic):2+inet(evdev)" };
xkb_geometry { include "pc(pc105)" };
};
then neither setxkbmap -query
nor xkbswitch -l
shows the loaded layouts, but instead those loaded on system startup, but they can be switched to.
Does someone know why?
I am getting the following error on Ubuntu 20.04 when running the command
xkb-switch: error while loading shared libraries: libxkbswitch.so.1: cannot open shared object file: No such file or directory
It would be great to check required -dev libraries installed in the system
Can't detect current keyboard layout in Wayland session.
Hello,
I notice that the github releases page (currently 1.6.0) does not follow the version numbers from the git (1.8.5). Are you not planning to use the release feature of github anymore?
I've built the latest master (6cd4da9). I'm on Xubuntu 18.04 using i3. Had to sudo apt install libsigc++-2.0-dev libxkbfile-dev
for a successful build.
Problem is, I can't change the layout from us
to anything:
./xkb-switch -s ir
xkb-switch: /home/pooya/tools/utility/xkb-switch-i3/src/XKbSwitch.cpp:221: Condition i!=syms.end() failed. Group 'ir' is not supported by current layout. Try xkb-switch -l.
xkb-switch: layouts: [us]
de
or ru
also yields similar result.
./xkb-switch -l
us
Here is the script I use to change layouts:
#!/bin/bash
CURR_LANG="$(setxkbmap -query | grep layout | tr -s ' ' | cut -d ' ' -f2)"
US="us"
IR="ir"
if [[ "$CURR_LANG" == "$US" ]]
then
setxkbmap ir
else
setxkbmap us
fi
λ ./xkb-switch -d
[DEBUG] xkb-switch version 1.8.1
[DEBUG] layout: us
[DEBUG] variant: <empty>
us
λ ./xkb-switch -d
[DEBUG] xkb-switch version 1.8.1
[DEBUG] layout: ir
[DEBUG] variant: <empty>
ir
Am I using the program correctly?
I tried to build the program on ubuntu 18.04 using this instruction
https://github.com/ierton/xkb-switch#installing
sudo apt update
cd ~/Downloads
mkdir xkb-switch
tar -xvzf xkb-switch-1.6.0.tar.gz -C xkb-switch
cd xkb-switch/xkb-switch-1.6.0
mkdir build && cd build
sudo apt install cmake
cmake ..
but got the following error:
CMake Error at /usr/share/cmake-3.10/Modules/FindX11.cmake:429 (message):
Could not find X11
Call Stack (most recent call first):
CMakeLists.txt:11 (FIND_PACKAGE)
-- Configuring incomplete, errors occurred!
See also "/home/rom/Downloads/xkb-switch/xkb-switch-1.6.0/build/CMakeFiles/CMakeOutput.log".
Could you help me, please?
With last updates to xkbswitch
the vim-xkbswitch plugin crashes with the following error:
vim: symbol lookup error: /usr/local/lib/libxkbswitch.so: undefined symbol: _ZN2kb6parse2ERKSsRKSt6vectorISsSaISsEE
Also, is it still true that you are going to stop maintaining this project?
There was xkb-switch package for Ubuntu 18, but there is none for Ubuntu 20.04.1 LTS.
Hello,
Not really an issue, but a feature request.
Could you add an option to show layout variant as well as layout?
Preferably in a way that works with -W flag.
When xkb-switch
is compiled with -O2
flag, libcalls from Vim fail to correctly change the layout when going from insert mode back to normal. There are no error messages in Vim during execution.
See vim-xkbswitch #27 for related discussion.
Since the problem is quite vague, here's the screencast that demonstrates the issue: xkb-switch problems
Generally the change of execution behavior with -O2
indicates of some issues with the source code.
I assume you have removed the -x
option at some point.
Still, wanted to clarify, since Readme says:
Xkb-switch contains some testing facilities, please include output of `xkb-switch -x' command in the report.
I wanted to use this feature to investigate another issue (possibly not event with xkb-switch, tbh)
p.s. I use version 1.4.0
Fox xkb_symbols string like pc+us+ru(winkeys):2+ua(winkeys):3+inet(evdev)+group(toggle)
running with non-first group active produces error
terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check
It seems that symbols followed by '(' should not be ignored unconditionally like they do since 42abcc0.
Basically is there a proper way to may it work on wsl2?
The question is in the title :)
I want to make sure I'm not missing anything.
> git clone
> build && cd build
> cmake ..
> make
Scanning dependencies of target xkb-switch
[ 16%] Building CXX object CMakeFiles/xkb-switch.dir/XKbSwitch.cpp.o
[ 33%] Building CXX object CMakeFiles/xkb-switch.dir/XKeyboard.cpp.o
/home/dell/Desktop/xkb-switch/XKeyboard.cpp:19:37: fatal error: X11/extensions/XKBrules.h: No such file or directory
compilation terminated.
CMakeFiles/xkb-switch.dir/build.make:86: recipe for target 'CMakeFiles/xkb-switch.dir/XKeyboard.cpp.o' failed
make[2]: *** [CMakeFiles/xkb-switch.dir/XKeyboard.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/xkb-switch.dir/all' failed
make[1]: *** [CMakeFiles/xkb-switch.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
Hello everyone !
I develop analog PuntoSwitcher for Windows. It is OpenSwitcher and its github here OpenSwitcher.
I faced with a problem when I use xkb-switch
in xbindkeys
. At first run xbindkeys
key combination Ctr+Alt script run correctly but i another cases it doesnt work. Without xkb-switch
xbindkeys
key combination Ctr+Alt script run normaly.
Code here:
$HOME/.xbindkeysrc
# Activate OpenSwitcher
# To read about how to customise read `man xbindkeys`
# To read where is keys see #include <X11/keysym.h>
"openswitcher.sh"
Control + Alt_L
/usr/local/bin/openswitcher.sh
# sleep 0.5
xkb-switch -n
sleep 0.5
xsel | sudo openswitcher
uname -a
Linux MyDebian 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.38-2 (2023-07-27) x86_64 GNU/Linux
goodchar() precludes digits, so a group containing a digit won't be recognized.
I stumbled upon this because I defined my own keymap, to which I appended a number.
I understand that "normal people" won't encounter this bug, but perhaps it's worth mentioning this in the README for the sake of abnormal people...
How can I enable C++ 11 support for build? Is there a working version of commands cmake
and/or make
commands with options? I am trying to make RPM package for Rosa Linux R8, using cmake v3.5.2 and gcc v4.9.4. It seems, the simplest way is to edit CMakeLists.txt:
change CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
to version 3.1, and add a string (that works only for cmake 3.1 and higher) after project's name and version definition
set(CMAKE_CXX_STANDARD 11)
Reproduce:
xkbcomp my $DISPLAY
./xkb-switch
Expected:
xkb-switch/build $ ./xkb-switch
ru
Got:
xkb-switch/build $ ./xkb-switch
xkb-switch: vector::_M_range_check: __n (which is 1) >= this->size() (which is 1)
xkb-switch: layouts: [us]
(Exit code 2)
OS: Mint 19 tara
I expect it to output a name right from the start and not to wait for a change. It would be useful in i3blocks with 'persist' interval.
Hello! Thank you very much for this plugin. I tried everything but this one, it seems very close to solution. I am using Regolith i3 and I tried https://github.com/zebradil/xkb-switch-i3 it tracks only window language, and doesn't track when I change language.
And the xkb-group.sh us ru shows:
trap: SIGINT: bad trap
trap: SIGTERM: bad trap
There xkb-switch v. 1.8.1
When I am trying your plugin v. 1.8.5
./xkb-switch -d
[DEBUG] xkb-switch version 1.8.5
/home/lastgosu/work/xkb-switch/src/XKeyboard.cpp:110: raw layout string "us,ru,us"
/home/lastgosu/work/xkb-switch/src/XKeyboard.cpp:111: raw variant string ",,"
[DEBUG] layout: us,ru,us
[DEBUG] variant: ,,
/home/lastgosu/work/xkb-switch/src/XKeyboard.cpp:127: layout "us", variant ""
/home/lastgosu/work/xkb-switch/src/XKeyboard.cpp:136: ... accepting with id #0
/home/lastgosu/work/xkb-switch/src/XKeyboard.cpp:127: layout "ru", variant ""
/home/lastgosu/work/xkb-switch/src/XKeyboard.cpp:136: ... accepting with id #1
/home/lastgosu/work/xkb-switch/src/XKeyboard.cpp:127: layout "us", variant ""
/home/lastgosu/work/xkb-switch/src/XKeyboard.cpp:136: ... accepting with id #2
/home/lastgosu/work/xkb-switch/src/XKeyboard.cpp:127: layout "", variant ""
./xkb-switch -l
us
ru
us
./xkb-switch -W and -w is working
./xkb-switch -n not working
Test is failing.
Thank you for any help.
Ubuntu 21.04 Regolith i3 1.6
Layouts ru-us
On Gnome Ubuntu everything is the same except the test, it is passing.
After a fresh install of Debian 9 (stretch), with Gnome 3.20, xkb-switch
compiles and seems to run fine, but it actually does nothing:
$ xkb-switch
'us(dvp)'
$ xkb-switch -s 'fr(bepo)'
$ xkb-switch
'us(dvp)'
$ xkb-switch -n
$ xkb-switch
'us(dvp)'
Here are two interesting outputs:
$ cat /etc/default/keyboard
XKBLAYOUT=us,fr,fr
XKBVARIANT=dvp,bepo,oss
BACKSPACE=guess
$ xkb-switch -l
us(dvp)
fr(bepo)
fr(latin9)
fr(oss)
.. are they not unconsistent? Could it cause a crash? Any idea what may be going wrong? It used to work just fine with Debian 8 (jessie) and Gnome 3.14.
I work with typo layouts so I see 'us+typo' and 'ru:2+typo' instead of usual 'us' and 'ru'. I wrote a program that behaves like xkb-switch with -W flag but prints 'English (US)' and 'Russian'. Those names are available from the Xlib itself, you do not need to write any additional strings. Could you please add a flag for that?
Hello, when i install it as user, i run make DESTDIR=$HOME/.local install
, i get this
[ 50%] Built target xkbswitch
[ 83%] Built target xkb-switch
[100%] Built target man_xkb-switch_1
Install the project...
-- Install configuration: ""
-- Up-to-date: /home/kalium/.local/usr/local/bin/xkb-switch
-- Up-to-date: /home/kalium/.local/usr/local/lib/libxkbswitch.so.2.0.1
-- Up-to-date: /home/kalium/.local/usr/local/lib/libxkbswitch.so.2
-- Up-to-date: /home/kalium/.local/usr/local/lib/libxkbswitch.so
-- Up-to-date: /home/kalium/.local/usr/local/share/man/man1/xkb-switch.1.gz
which is strange. shouldn't it be
...
-- Up-to-date: /home/kalium/.local/bin/xkb-switch
-- Up-to-date: /home/kalium/.local/lib/libxkbswitch.so.2.0.1
-- Up-to-date: /home/kalium/.local/lib/libxkbswitch.so.2
-- Up-to-date: /home/kalium/.local/lib/libxkbswitch.so
-- Up-to-date: /home/kalium/.local/share/man/man1/xkb-switch.1.gz
is that a problem? or it should be like this?
Thanks very much
I think it's time to define versioning principles for this project. Is version number maintained only by project's owner or contributors must change it themselves? When to change release version, for each successful build or when any issue is closed? When to change minor version? Maybe when an issue closed or only when API is changed? What means the major version?
I propose to include this information into README.
I have an error when compiling XKeyboard.cpp
file, using gcc compiler with option -std=gnu++11
. It says that '=' operator for istringstream
is deleted. From documentation, it seems that Copy operator is deleted. Maybe it's better to use stringstream
with operator <<
instead?
I'm on Xubuntu 18.04. Had to change these lines in CMakeCache.txt
from gz
to gzip
COMPRESS_EXECUTABLE:FILEPATH=/bin/gzip
MAN_COMPRESSION:STRING=gzip
We need replace homegrown command-line arguments parser with getopt
or alike. The goal is to make xkb-switch
CLI handling more standard. For example, now it doesn't process 'tightly coupled' one-letter flags, like -ld
instead of -l -d
. Getopt family of functions could do it.
Contributions are welcome here.
XKbSwitch.cpp
getopt
family of C functionsCMakeLists.txt
if required./test.sh
still prints OKPlease, do not introduce non-standard dependencies like boost. Use stdlib C or C++ < 11 tools.
If I build and install this program from source I get the following error when running man xkb-switch.1
:
man: warning: /usr/local/man/man1/xkb-switch.1.gzip: ignoring bogus filename
I will make a pull request to fix this issue.
branch test: Updated 7 years ago by ierton.
May be delete?
Hey, this was initially reported here but I see that you recently changed something in your CMakeLists.txt regarding man
. Specifically, after installing I get this error:
$ man 1 xkb-switch
man: warning: /usr/share/man/man1/xkb-switch.1.xz.gz: ignoring bogus filename
No manual entry for xkb-switch in section 1
I follow a very simple installation process: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=xkb-switch
Hello everyone, I faced with a problem when I use xkb-switch
in my project OpenSwitcher I tried several tests but result shows that problem appears exactly after using xkb-switch
. OpenSwitcher uses actkbd to run when Ctr_L+Alt_L combination is pesses
Test 1 in script/openswitcher.sh
#!/bin/bash
xkb-switch -n
sleep 1
xsel -o | sudo openswitcher --verbose --device "$(input-device-info.sh)"
Result: text changed only at first time.
Test 2 in script/openswitcher.sh
#!/bin/bash
#xkb-switch -n
#sleep 1
xsel -o | sudo openswitcher --verbose --device "$(input-device-info.sh)"
Hi,
I have an issue when I'm configuring multiple keyboard at the same time. (with only 1 keyboard, it's always ok)
Actually, I'm using xkb-switch just to know which keyboard is the ACTIVE one, but in some case it return the wrong keyboard:
Configured : German, French, US-Intl
Default one: French
xkb-switch is always giving to me the active one, even when I switch with shortcut CTRL-SHIFT... Perfect...
BUT:
Configured : German, French, US-Intl
Default one: German
kxb-switch is not correct... He is mixing French and US-Intl:
Active keyboard: German --> xkb-result : de
Active keyboard: French --> xkb-result : US-Intl
Active keyboard: US-Intl --> xkb-result : fr(winkeys)
Os: Ubuntu 10.04 / XFCE / ARM CPU
I don't know how to set variant. There's no documentation on it. I'd like to use colemak_dh, but there's no way for me to specify this to xkb-switch or xkb-group.sh
GPL is too strict of a license for some purposes: many companies disallow using any GPL open-source libraries. I would like to create in the future a derived project, and I would like to use MIT license for it. But GPL does not allow to do such thing (I would have to use GPL). Is there any possibility for xkb-switch to switch to a less strict license?
Hello, I'd like it if this tool had options for showing the keyboard layout and variant separately, e.g. us
and intl
. For example:
$ xkb-switch -a
intl
$ xkb-switch -b
us
$ xkb-switch -p
us(intl)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.