Tiny Core Linux

Tiny Core Base => TCB Q&A Forum => Topic started by: Scampada on March 06, 2017, 06:31:15 AM

Title: Switching keyboard layouts in Xfbdev?
Post by: Scampada on March 06, 2017, 06:31:15 AM
Anybody knows how to get layout switching working using Xfbdev?

Xserver: Xfbdev
Window manager: dwm

I tried using setxkbmap but got an error:
XKB extension not present on :0

So, it looks for me that xkb tools are designed for use with Xorg only.
I was also able to get needed characters with xmodmap, but as far as I could understand I only could type them holding the 'Super' modificator. It's not quite comfortable. What should I do to get a permanent layout switch? Is it possible for Xfbdev?
Title: Re: Switching keyboard layouts in Xfbdev?
Post by: curaga on March 06, 2017, 11:03:25 AM
TinyX uses the keymap from the console. I don't think it's possible to use two layouts switched by a button, at least traditionally (you could bind that key to xmodmap invocations through your WM or other method).
Title: Re: Switching keyboard layouts in Xfbdev?
Post by: Scampada on March 06, 2017, 11:07:39 AM
Okay, can you please give me a hint for easy binding a key to some kind of xmodmap (or other) invocation? I don't know what should I google. DWM, Xfbdev (it's TinyX now?).

I can make two different xmodmap map files, then and rotate them by pressing a key button.
Title: Re: Switching keyboard layouts in Xfbdev?
Post by: Scampada on March 06, 2017, 11:17:24 AM
Okay, okay, sure, it's something about xbindkeys. Sorry for bothering.
Title: Re: Switching keyboard layouts in Xfbdev?
Post by: Scampada on March 06, 2017, 01:55:05 PM
Йоб done!

(https://pp.userapi.com/c626516/v626516354/4dbfb/JaDKTZWZgFI.jpg)

(https://pp.userapi.com/c626516/v626516354/4dbf3/G8lFDnBBIzo.jpg)
Title: Re: Switching keyboard layouts in Xfbdev?
Post by: jazzbiker on November 07, 2020, 02:15:19 AM
Hi, all!

This topic presents the correct method of solving the problem, but without details, so I want to share my results, they may be used directly by newcomers and advanced by the experienced Core users.
I use ru_RU.UTF-8 locale and will use it as an example.

Traditional TC localization steps:
Code: [Select]
tce-load -w getlocale.tcz
tce-load -i getlocale.tcz
getlocale.sh
# script will ask You for locales to load and will create Your personalized mylocale.tcz extension

echo "mylocale.tcz" >> "$(readlink /etc/sysconfig/tcedir)"/onboot.lst

# then add the exact name of locale chosen to Your bootcodes : lang=ru_RU.UTF-8

tce-load -w setfont.tcz
tce-load -i setfont.tcz

#choose appropriate font in /usr/local/share/consolefonts directory
#in my case it is UniCyr_8x16.psf.gz
#and load this font during boot

echo "setfont.tcz" >> "$(readlink /etc/sysconfig/tcedir)"/onboot.lst
echo "setfont UniCyr_8x16" >> /opt/bootlocal.sh

#next is console keyboard mapping

tce-load -w kmaps.tcz
tce-load -i kmaps.tcz
echo "kmaps.tcz" >> "$(readlink /etc/sysconfig/tcedir)"/onboot.lst

#choose desired keymapping in /usr/local/share/kmap
#for me it is qwerty/ ruwin_ct_sh-UTF-8.kmap
#and add appropriate bootcode to Your bootloader config : kmap= ruwin_ct_sh-UTF-8

All this was around console localization and it is desirable for flawless Xfbdev localization, though console kmaps probably may be omitted, You can try if You want.

Now start Xfbdev, create layouts directory, f.e.
Code: [Select]
cd
mkdir layouts
and capture the default X keymapping:
Code: [Select]
xmodmap -pke > ~/layouts/default.xkmap
then create alternative ( in the example russian ) layout:
Code: [Select]
cat << EOF > ~/layouts/russian.xkmap
keycode  24 = Cyrillic_shorti Cyrillic_SHORTI
keycode  25 = Cyrillic_tse Cyrillic_TSE
keycode  26 = Cyrillic_u Cyrillic_U
keycode  27 = Cyrillic_ka Cyrillic_KA
keycode  28 = Cyrillic_ie Cyrillic_IE
keycode  29 = Cyrillic_en Cyrillic_EN
keycode  30 = Cyrillic_ghe Cyrillic_GHE
keycode  31 = Cyrillic_sha Cyrillic_SHA
keycode  32 = Cyrillic_shcha Cyrillic_SHCHA
keycode  33 = Cyrillic_ze Cyrillic_ZE
keycode  34 = Cyrillic_ha Cyrillic_HA
keycode  35 = Cyrillic_hardsign Cyrillic_HARDSIGN
keycode  38 = Cyrillic_ef Cyrillic_EF
keycode  39 = Cyrillic_yeru Cyrillic_YERU
keycode  40 = Cyrillic_ve Cyrillic_VE
keycode  41 = Cyrillic_a Cyrillic_A
keycode  42 = Cyrillic_pe Cyrillic_PE
keycode  43 = Cyrillic_er Cyrillic_ER
keycode  44 = Cyrillic_o Cyrillic_O
keycode  45 = Cyrillic_el Cyrillic_EL
keycode  46 = Cyrillic_de Cyrillic_DE
keycode  47 = Cyrillic_zhe Cyrillic_ZHE
keycode  48 = Cyrillic_e Cyrillic_E
keycode  49 = Cyrillic_io Cyrillic_IO
keycode  52 = Cyrillic_ya Cyrillic_YA
keycode  53 = Cyrillic_che Cyrillic_CHE
keycode  54 = Cyrillic_es Cyrillic_ES
keycode  55 = Cyrillic_em Cyrillic_EM
keycode  56 = Cyrillic_i Cyrillic_I
keycode  57 = Cyrillic_te Cyrillic_TE
keycode  58 = Cyrillic_softsign Cyrillic_SOFTSIGN
keycode  59 = Cyrillic_be Cyrillic_BE
keycode  60 = Cyrillic_yu Cyrillic_YU
EOF

and now You can change layouts using:
Code: [Select]
cat ~/layouts/russian.xkmap | xmodmap -
cat ~/layouts/default.xkmap | xmodmap -

Don't forget to use UTF-compatible terminal (for example rxvt.tcz) and load UTF-8  fonts.

The trap on Your shiny way is, that when You have changed the layout to the local one, You loose the possibility to enter commands 8-0 . This trouble may be overcomed by using the small script in the separate terminal window, which will do all the work, controlled by Enter key pressed
Code: [Select]
while true
do
  cat ~/layouts/default.xkmap | xmodmap -
  echo "default"; read
  cat ~/layouts/russian.xkmap | xmodmap -
  echo "russian"; read
done

This is the simplest way, not requiring any additional software. Maybe You will want to use xbindkeys.tcz to perform the better solution.

In order to create Your own layout for Your locale You will need xorg-proto.tcz inatalled and /usr/local/include/X11/keysymdef.h  file, which defines symbol names (excluding XK_ prefix).
That's all, folks. Don't forget to share Your keymappings.

Have a nice Xfbdev!