HowTo: Adapt Sailfish virtual keyboard (vkb) layout
asked 2014-01-31 02:24:37 +0200
This post is a wiki. Anyone with karma >75 is welcome to improve it.
It is quite easy to adapt the virtual keyboard of Sailfish OS in such a way, that you do not spoil any of the original layouts and that it also should survive a system update. While you can do it all on the Jolla handset itself, I personally prefer using a PC for it.
See also answers
- HowTo: vkb layout file available from internet
- HowTo: Shorten the delay until accented characters appear
- HowTo: Remove unwanted keyboard layouts from the long-tap space selection
- HowTo: Add cursor (arrow) keys to your keyboard
- Wiki: Changes from Sailfish OS 1.0.3.8 to 1.0.4.20
If you want to get capital letters in the lower case keyboard level by long-tapping, you might be interested in the post https://together.jolla.com/question/28819/howto-long-press-character-keyboard-for-capitalization/.
Newer Sailfish versions
- With Sailfish OS 1.0.4.20 the keyboard code in directory
/usr/share/maliit/plugins/com/jolla/
has been changed, including Popper.qml and InputHandler.qml. Check Wiki: Changes from Sailfish OS 1.0.3.8 to 1.0.4.20 to see what this means for your particular code amendments.
The procedure below works also for Sailfish OS 1.0.4.20.
1 What you need
- Developer mode activated (including ssh access when using the PC; see below).
- An Unicode capable editor (UTF-8), I prefer SciTE (http://www.scintilla.org). (Alternatively you may use vi directly on the Jolla handset -- but if you can use this, you do not need the following instructions ;-)
- USB access from your PC to your Jolla handset
- FileBrowser app on your Jolla handset (get it from the Jolla Store)
- Optional: An ssh client, I prefer Cygwin Terminal. (Alternatively you may use Terminal on the Jolla handset.)
- Optional, only when using an ssh client: WiFi access from your PC to your Jolla handset
2 Procedure
See answer vkb layout file available from internet if you have found a layout file on the internet that suits you.
2.1 Developer mode
- Go to |- Settings | System Settings | Developer Mode -|. ( Because your Jolla device can access the Jolla apps shop, a Terminal app is installed now.)
- Activate „Developer mode“.
- Activate „Remote connection” (either enter and [Save] a password or [Generate] it; if you generate it, you have to edit it slightly before the [Save] button becomes available).
- Note the WiFi IP address shown under ""Networking".
2.2 Getting the layout template
- Open FileBrowser.
- From the pulley menu select "Go to home".
- Using the 3 dots in the top left, go to the root of the file system (no dot being shown any longer).
- Go down in the file system to (tapping each of the directory icons): /usr/share/maliit/plugins/com/jolla/layouts/
- Look for the qml file of the language you want to use as a template, e.g. de.qml for German.
- Tap-and-hold that file.
- From the context menu opening select "Copy".
- From the pulley menu select "Home".
- Go down to directory "Downloads".
- From the pulley menu select "Paste".
- Connect Jolla handset and PC via USB.
- When requested, select "PC connection".
- Using your PC file browser (e.g. Windows Explorer) go to the "Sailfish" device, directory "Downloads" (in Windows, the address line should show: "Computer\Sailfish\Phone Memory\Downloads").
- Copy the previous qml file onto your PC.
- Rename the qml file suitably, e.g. de.qml into dex.qml (x = extended)
2.3 Editing the template
- Open the renamed qml file in the text editor of your choice.
- Make sure, the character coding is set to UTF-8 (in SciTE: |- File | Encoding | UTF-8 -|.
Study the file contents. You have
- 3 entries "KeyboardLayout" corresponding to the 3 rows of keys (except the lowest one with the space bar).
- 7 or 11 "CharacterKeys" in each row corresponding to the actual keys.
- For each CharacterKey a
- "caption": lower case letter
- "captionShifted": upper case letter
- "symView": 1st level figure/symbol character
- "symView2": 2nd level figure/symbol character
- "accents": The list of characters appearing when you tap-and-hold a key in the lower case letter level
- "accentsShifted": The list of characters appearing when you tap-and-hold a key in the upper case letter level
- 1 entry "SpacebarRow": A reference for the space bar row definitions. (You may change even this row, check file http://bundyo.org/jolla/layouts/bg.qml.)
Most interesting probably are changes to the "accents" and "accentsShifted" entries, you may add such entries for any key not yet having such entry. For example, I created a keyboard layout where each key of the upper row includes a number from 1 to 9 and 0 in the accents and accentsShifted and the most right key holding some special characters such as @.
You may even add or remove keys (add/remove a "CharacterKey" statement). However, 11 keys in the upper rows seems to be a natural maximum, thereafter the key space gets too small to be usable (at least for me).
When finished with editing, save the file.
2.4 Creating a config file
In order that Sailfish recognizes your newly created layout, you need a config file. This should have the same name as the layout file, except for the extension being "conf", i.e. dex.conf. The contents should be:
[dex.qml]
name=DeutschX
languageCode=DE
With:
- 1st line: file name of layout file
- 2nd line: indicating the language as shown when tap-and-holding the space bar of the vkb
- 3rd line: international language code as shown on the space bar
Create such file on your computer, e.g. using SciTE.
2.5 Copying the layout and config file back onto the Jolla handset
Because the Sailfish FileBrowser cannot copy files into the system directories, you need command line access to the handset.
- Using the file browser of your computer copy the 2 files back to the Download directory of the Jolla device.
- If you want to use an ssh client (instead of typing on the command prompt of the Sailfish Terminal):
- On the PC start the ssh client (e.g. Cygwin Terminal).
- Connect to the Jolla device: On the command line enter:
xxx.xxx.xxx.xxx -l nemo
and [Enter]. (xxx.xxx.xxx.xxx being the WiFi IP address you noted earlier; "-l" = hyphen + lower case L).
(The ssh client connects to the handset and asks for the password. If it should not connect, somehow the PC does not find the way to the Jolla. Check your firewall. On my system for example, I can only connect when the PC is connected to the router via cable. If it still does not work: Use the Sailfish Terminal.) - When prompted for the password, enter the "Remote connection" password you created earlier and [Enter].
(The command line prompt of Sailfish appears, the prompt will be "$". You are logged in as user.)
- If you want to use the Sailfish Terminal app (as installed when activating the developer mode):
- Start Terminal.
(The command line prompt of Sailfish appears, the prompt will be "$". You are logged in as user.)
From now on be careful, what you are doing. As administrator you may break your handset!
Continue with either, ssh client or Terminal as follows: - Start Terminal.
- On the command line enter
devel-su
and [Enter]. (You are asked for a password.) - When prompted for the password, enter the "Remote connection" password you created earlier and [Enter].
(The command line prompt changes to "#". You are logged in as administrator.) - Copy the files created to the layout directory: Enter
cd /home/nemo/Downloads
and [Enter]
(Observe the upper case "D" in Downloads -- you are talking Linux where file/directory names are case sensitive). - Check that you are in the right directory and your files are there: Enter
dir
and [Enter].
(In the list shown, your files should be included.) - Copy the layout file: Enter
cp dex.qml /usr/share/maliit/plugins/com/jolla/layouts/
and [Enter]
(Instead of dex.qml note your own file). - Copy the layout file: Enter
cp dex.conf /usr/share/maliit/plugins/com/jolla/layouts/
and [Enter]
(Instead of dex.conf note your own file). - Reset the keyboard service: Enter
killall maliit-server
and [Enter].
NOTE: Disable "Remote access" again before connecting to networks you cannot trust (e.g. public WiFi networks, mobile providers that do not allocate private IP 4 addresses and block inter-user IP communication – assume, they do not, as long as you do not know they do). Otherwise, strangers could try to enter your phone via ssh and try passwords using an automated procedure until they have been successfully entering your phone.
2.6 Selecting the new keyboard layout
- Open any application that shows the keyboard.
- Tap-and-hold the space bar. (The languages available are displayed.)
- From the languages list select your language (as stated in the your conf file).
Enjoy.
PS: Helpful was http://talk.maemo.org/showthread.php?t=91917 found by @ssahla, see https://together.jolla.com/question/19999/cant-type-en-dash-on-virtual-keyboard/.
Initially created by: @jgr
Nice writeup! It would be perfect to have cursor keys for the keyboard, as scrollback is problematic with some text input fields (e.g. this comment/reply field with the Jolla native browser). I have however no clue how to place those four keys without losing otherwise important keys. Ideas welcome.
marsch ( 2014-01-31 03:11:49 +0200 )edit@marsch: check that talk.maemo.org link above. That thread has keyboards with cursors keys (2 or 4 way as well), you can proceed from there :-) Ps: It is not only the placement on the vbk, you have to slightly modify the input handler as well, but don't worry, not difficult... :)
CsTom ( 2014-01-31 13:31:33 +0200 )editAs far as I understand it: You can code cursor keys (all 4) -- but for each one you code, you loose one key position (all four levels, i.e. lower case, upper case, symbol 1 and symbol 2 and including tap-and-hold option). For a German keyboard a hard decision ...
jgr ( 2014-01-31 23:42:54 +0200 )editWhy would you loose any key position? o.O The key positions are not fixed. True, if you have more keys, it gets more cramped, but you don't loose positions -- as there are no positions. Check again that maemo.org link above, there are a few vbk pictures there, so you can see many more keys can fit there than just the english letters...
CsTom ( 2014-02-01 00:59:52 +0200 )editwell, need it on jolla store keyboard-language CH-fr without developer mode.
redge73 ( 2014-02-02 02:11:15 +0200 )edit