File: phosh-osk-stub.rst

package info (click to toggle)
phosh-osk-stub 0.46.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,132 kB
  • sloc: ansic: 11,191; xml: 1,567; python: 142; makefile: 15; sh: 10
file content (298 lines) | stat: -rw-r--r-- 9,736 bytes parent folder | download
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
.. _phosh-osk-stub(1):

==============
phosh-osk-stub
==============

-------------------------------
An on screen keyboard for Phosh
-------------------------------

SYNOPSIS
--------
|   **phosh-osk-stub** [OPTIONS...]


DESCRIPTION
-----------

``phosh-osk-stub`` is an on screen keyboard (OSK) for phosh. It can
replace Phosh's default keyboard ``squeekboard(1)``.

``phosh-osk-stub`` has two modes of operation. If the application
supports and uses ``text-input-unstable-v3`` the Wayland compositor
will use the ``input-method-unstable-v2`` protocol to interact with
the OSK. This allows it to

- automatically unfold the keyboard
- handle text prediction / correction via preedit and surrounding text
- automatically switch to special layouts like to terminal by input
  hints sent from the application

This is the preferred mode of operation. For legacy applications like
e.g. Electron applications the OSK falls back to a virtual keyboard mode
(basically emulating key presses). This means that it e.g. can't unfold
automatically or support completion. It will hence hide the completion bar
in that mode of operation.


OPTIONS
-------

``-h``, ``--help``
   Print help and exit

``--replace``
   Try to grab the `sm.puri.OSK0` DBus interface, even if it is
   already in use by another keyboard.

``--allow-replacement``
   (Temporarily) Give up the `sm.puri.OSK0` DBus name if another OSK
   requests it. This also unregisters the Wayland input-method-v1 so another
   OSK can act as input method.
   If the name becomes available again it is grabbed again and phosh-osk-stub
   registers itself as input method again.

``-v``, ``--version``
   Show version information


SETUP
-----

In order to be used by Phosh as OSK, phosh-osk-stub needs to be started from
the `/usr/share/applications/sm.puri.OSK0.desktop` desktop file. On Debian
systems this can be achieved by running

::

   update-alternatives --config Phosh-OSK

as root and selecting the entry ending in ``sm.puri.Phosh.OskStub.desktop``.


CONFIGURATION
-------------

``phosh-osk-stub`` is configured via ``GSettings``. This includes
configuration of the loaded layouts from
``org.gnome.desktop.input-sources`` via the ``sources`` and
``xkb-options`` keys, whether the OSK is enabled at all via the
``org.gnome.desktop.a11y.applications``'s ``screen-keyboard-enabled`` and
configuration of word completion (see below).

For the keyboard to fold and unfold automatically make sure
``org.gnome.desktop.interface`` ``gtk-im-module`` is set to the empty string
(`''`).  This is the default in most distributions. If unsure check via:

::

  gsettings get org.gnome.desktop.interface gtk-im-module


WORD COMPLETION
^^^^^^^^^^^^^^^

``phosh-osk-stub`` has support for word completion and correction via various
completers (see below). It has several modes of operation represented
by flags that can be combined:

- `off`: no word completion
- `manual`: enable and disable completion via an option in the language popover
- `hint`: enables and disables completion based on the text input's `completion`
  hint.

Valid settings are `off`, `manual`, `hint` and `manual+hint`. These can be
enabled configured via the `gsettings` command:

::

  # off
  gsettings set sm.puri.phosh.osk completion-mode "[]"
  # manual
  gsettings set sm.puri.phosh.osk completion-mode "['manual']"
  # hint
  gsettings set sm.puri.phosh.osk completion-mode "['hint']"
  # manual+hint
  gsettings set sm.puri.phosh.osk completion-mode "['manual','hint']"
  # Reset to default (off)
  gsettings reset sm.puri.phosh.osk completion-mode

Note that completion is always disabled when

- No usable completers are found on startup
- Terminal or emoji layout is in use
- The application doesn't support text-input so ``phosh-osk-stub`` is
  falling back virtual-keyboard mode.


AVAILABLE COMPLETERS
####################

The available completers depend on how ``phosh-osk-stub`` was
built. Available are currently at most

  - ``hunspell``: word correction based on the hunspell library
  - ``presage``: (experimental) word prediction based on the presage library
  - ``pipe``: completer using a pipe
  - ``fzf``: completer based on fzf command line tool. Useful for experiments)
  - ``varnam``: completer using govarnam for Indic languages

The default word completer is selected via the
``sm.puri.phosh.osk.Completers`` ``default`` GSetting.

::

  gsettings set sm.puri.phosh.osk.Completers default hunspell

You need to restart ``phosh-osk-stub`` for the new default completer
to become active.


TEXT CORRECTION USING HUNSPELL
******************************

The hunspell completer needs dictionaries and affix files in
``/usr/share/hunspell`. Most importantly ``/usr/share/hunspell/en_US.dic``
and ``/usr/share/hunspell/en_US.aff`` are required as fallback when no
matching dictionary for the current layout is found.


TEXT COMPLETION USING PRESAGE
*****************************

The presage based completer is considered experimental as there are
some known issues when interacting with GTK4 applications.

For the presage based completer to work you need a model file in
`/usr/share/phosh/osk/presage/`. Likely your distribution already
ships one with the presage library. You can simply symlink it
there.  Models for more languages can be found in
https://gitlab.gnome.org/guidog/phosh-osk-data


TEXT COMPLETION USING PIPE
**************************

This completer feeds the current input word (preedit) to an executable
file and expects the executable to output possible completions on
stdout. The executable to invoke is configured via the
``sm.puri.phosh.osk.Completers.Pipe`` ``command`` GSetting. It defaults
to ``cat``. This can be used to experiment with different completion
patterns without having to modify ``phosh-osk-stub`` itself.

::

  gsettings set sm.puri.phosh.osk.Completers.Pipe command 'wc -c'

You need to restart ``phosh-osk-stub`` for the new command to become
active. A commonly used executable is swipeGuess: https://git.sr.ht/~earboxer/swipeGuess


TEXT COMPLETION USING VARNAM
****************************

This completer feeds the current input word (preedit) to govarnam for easy
input of Indic languages.

For the completer to work it needs govarnam and the language schema
files installed. Please refer to the govarnam documentation.

Note that while you can enable govarnam as default completer this is
not recommended. Instead enable it for a specific language via the
`sources` gsettings:

::

  gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'us'), ('ibus', 'varnam:ml'), ('ibus', 'varnam:ta')]"

The above would only enable govranam for Malayalam and Tamil while the
English US layout would still use the default completer.

TERMINAL SHORTCUTS
^^^^^^^^^^^^^^^^^^
``phosh-osk-stub`` can provide a row of keyboard shortcuts on the
terminal layout. These are configured via the ``shortcuts`` GSetting

::

  gsettings set sm.puri.phosh.osk.Terminal shortcuts "['<ctrl>a', '<ctrl>e', '<ctrl>r']"

For valid values see documentation of `gtk_accelerator_parse()`: https://docs.gtk.org/gtk3/func.accelerator_parse.html
One can also add plain ``<ctrl>`` and ``<alt>`` keys. These then act as latched keys
until the next regular key is pressed.

IGNORING ACTIVATION
^^^^^^^^^^^^^^^^^^^
For some applications you might not want to unfold the OSK when the
application requests it. This can e.g. be useful when you usually read what
the application displays (and hence want to use as much as screen
space as possible) but the application focuses a text entry. By adding the
application's app-id to the ``ignore-activation`` list you can prevent the automatic
unfold. The OSK can still be unfolded by other means (e.g. via the DBus API or the OSK
button in Phosh). To determine an applications app-id you can use the
``foreign-toplevel`` command.

::

  gsettings set sm.puri.phosh.osk ignore-activation "['org.gnome.Calculator']"


HARDWARE KEYBOARDS
^^^^^^^^^^^^^^^^^^

By default the on screen keyboard will now show if it detects a
connected hardware keyboard. To make it show nevertheless use

::

   gsettings set sm.puri.phosh.osk ignore-hw-keyboards false


KEY PRESS
^^^^^^^^^

By default moving the finger while pressing a character will cancel
the gesture and not input it. This can be changed by enabling
`key-drag`:

::

   gsettings set sm.puri.phosh.osk osk-features "['key-drag']"


ENVIRONMENT VARIABLES
---------------------

``phosh-osk-stub`` honors the following environment variables for debugging purposes:

- ``POS_DEBUG``: A comma separated list of flags:

  - ``force-show``: Ignore the `screen-keyboard-enabled` GSetting and always enable the OSK. This
    GSetting is usually managed by the user and Phosh.
  - ``force-completion``: Force text completion to ignoring the `completion-mode` GSetting.
- ``POS_TEST_LAYOUT``: Load the given layout instead of the ones configured via GSetting.
- ``POS_TEST_COMPLETER``: Use the given completer instead of the configured ones.
  The available values depend on how phosh-osk-stub was built (see above).
- ``G_MESSAGES_DEBUG``, ``G_DEBUG`` and other environment variables supported
  by glib. https://docs.gtk.org/glib/running.html
- ``GTK_DEBUG`` and other environment variables supported by GTK, see
  https://docs.gtk.org/gtk3/running.html


EXAMPLES
--------

Use ``swipeGuess`` for swipe input:

::

   gsettings set sm.puri.phosh.osk.Completers default pipe
   gsettings set sm.puri.phosh.osk.Completers.Pipe command "swipeGuess /usr/local/share/swipeGuess/words/words-qwerty-en"
   gsettings set sm.puri.phosh.osk osk-features "['key-drag']"


See also
--------

``phosh(1)`` ``squeekboard(1)`` ``text2ngram(1)`` ``gsettings(1)`` ``hunspell(5)`` ``swipeGuess(1)``