平衡点
2017/02/01
_ VimFx での IM の制御
前回(平衡点(2017-01-26))の続き.
基本,作業環境はターミナルなので普段は IM は OFF になっていて欲しいので,vimperator を使っていた時には...
はい.お世話になっていました.
で,同様の事を VimFx でもできないかなぁ,とじたばた. VimFx/api.md at master · akhodakivskiy/VimFxあたりを眺めつつ,locationChange event あたりをひっかけたら良いかな,ということで.
const ibus_toggle = '/usr/local/bin/ibus-toggle'
const ibus_toggle_args = 'off'
// force ibus off when location changed
vimfx.on('locationChange', ({vim}) => {
let file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile)
file.initWithPath(ibus_toggle)
let process = Cc['@mozilla.org/process/util;1'].createInstance(Ci.nsIProcess)
process.init(file)
args = ibus_toggle_args.split(' ')
process.run(false, args, args.length)
})
と,こんな感じだろうか.とりあえず,日本語打つときは location bar での検索ぐらい(ページ内検索は XUL/Migemo)なので,ページ遷移があれば ibus を強制的に off にできるようになった.
あ,ibus-toggle の実態は
#!/bin/sh
[ -x /usr/bin/xdotool ] || exit 0
[ -x /usr/bin/ibus ] || exit 0
CURRENT_STATE=$(ibus engine)
case $@ in
on|ON|enable|Enable)
if [ ! ${CURRENT_STATE} = 'skk' ] ; then
xdotool key "Super+space"
fi
;;
off|OFF|disable|Disable)
if [ ! ${CURRENT_STATE} = 'xkb:us::eng' ] ; then
xdotool key "Super+space"
fi
;;
*)
# logger "ibus-toggle: toggle"
xdotool key "Super+space"
;;
esac
exit 0
と,こんな感じ.本当はibus engineで指定したい所なのだが,コマンドラインから切り替えると GNOME shell との表示が乖離してしまうので,xdotool でキー入力している.
[ツッコミを入れる]