fallback to cmd if Python's dbus module isn't available

closes #36.
This commit is contained in:
lilydjwg 2023-02-02 15:54:47 +08:00
parent dc95d0301b
commit 92247352c6

View file

@ -11,8 +11,7 @@ endif
let s:keepcpo = &cpo
set cpo&vim
" If g:fcitx5_remote is set (to the path to `fcitx5-remove`), use it to toggle IME state.
if exists("g:fcitx5_remote")
function s:setup_cmd()
function Fcitx2en()
let inputstatus = trim(system(g:fcitx5_remote))
if inputstatus == '2'
@ -32,6 +31,11 @@ if exists("g:fcitx5_remote")
endfunction
let g:loaded_fcitx = 1
endfunction
" If g:fcitx5_remote is set (to the path to `fcitx5-remove`), use it to toggle IME state.
if exists("g:fcitx5_remote")
call s:setup_cmd()
" Otherwise, if python3 is available, use python and dbus to toggle IME state.
elseif has('python3')
@ -50,6 +54,11 @@ elseif has('python3')
let g:loaded_fcitx = 1
endif
catch
if executable('fcitx5-remote')
let g:fcitx5_remote = 'fcitx5-remote'
call s:setup_cmd()
endif
endtry
endif