Skip to content

Commit

Permalink
🐛 Fix ibus backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Aug 4, 2024
1 parent 30e3735 commit 142cc02
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions lua/ime/backends/ibus.lua
Original file line number Diff line number Diff line change
@@ -1,42 +1,35 @@
-- luacheck: ignore 212/self
local lgi = require "lgi"
local p = require "dbus_proxy"
local proxy0 = p.Proxy:new(
{
bus = p.Bus.SESSION,
name = "org.freedesktop.IBus",
interface = "org.freedesktop.IBus",
path = "/org/freedesktop/IBus",
flags = lgi.Gio.DBusProxyFlags.DO_NOT_AUTO_START
}
)
local proxy = p.Proxy:new(
{
bus = p.Bus.SESSION,
name = "org.freedesktop.IBus",
interface = "org.freedesktop.IBus",
path = proxy0:CurrentInputContext(),
path = "/org/freedesktop/IBus",
flags = lgi.Gio.DBusProxyFlags.DO_NOT_AUTO_START
}
)
local M = {
proxy = proxy,
ascii_kbd = "xkb:us::eng",
non_ascii_kbd = "rime"
}

function M:enable_ascii()
M.proxy:Enable()
M.proxy:SetGlobalEngine(M.ascii_kbd)
end

function M:disable_ascii()
M.proxy:Disable()
M.proxy:SetGlobalEngine(M.non_ascii_kbd)
end

function M:is_ascii()
return M.proxy:IsEnabled()
return M.proxy:GetGlobalEngine()[3] == M.ascii_kbd
end

function M:current()
return M.proxy0:CurrentInputContext():gsub('.*/', '')
return M.proxy:GetGlobalEngine()[3]:sub("xkb:", ""):sub("::.*", "")
end

return M

0 comments on commit 142cc02

Please sign in to comment.