Monday, February 28, 2022

Switching between IBUS input methods....

Its great having the input method controller embedded into the Gnome taskbar so that input methods can be changed when moving between input windows using a keyboard command sequence. It would be useful too, if its was possible to keep tabs on what language is supposed to be used in a text widget and have the Tcl script switch input methods automatically. Here's how to do it...




# !/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"

package require Gnocl

set chn [gnocl::text]
set skt [gnocl::text]
set vb [gnocl::vBox]

$vb add $chn -fill 1 -expand 1
$vb add $skt -fill 1 -expand 1

gnocl::window -child $vb -setSize 0.4

$chn configure \
-onFocusIn  { eval exec "ibus engine pinyin"} \
-onFocusOut { eval exec "ibus engine xkb:gb:extd:eng" }

$skt configure \
-onFocusIn  { eval exec "ibus engine m17n:sa:IAST" } \
-onFocusOut { eval exec "ibus engine xkb:gb:extd:eng" }



No comments: