awesomewm/modules/ibus/widget.lua

73 lines
1.7 KiB
Lua
Raw Normal View History

local util = req_rel(..., "util")
local widget = {}
widget.ibus_indicator_text = wibox.widget.textbox("??")
widget.ibus_indicator_text.valign = "center"
widget.ibus_indicator_text.align = "center"
2023-08-21 19:00:27 -07:00
widget.ibus_indicator_text.font = config.core.font.normal_medium
widget.xkb_indicator_text = wibox.widget.textbox("??")
widget.xkb_indicator_text.valign = "center"
widget.xkb_indicator_text.align = "center"
2023-08-21 19:00:27 -07:00
widget.xkb_indicator_text.font = config.core.font.normal_small
widget.widget = wibox.widget {
{
{ -- Right spacer
widget = wibox.widget.separator,
color = beautiful.color.transparent,
forced_width = beautiful.dpi(3)
},
wibox.widget {
widget.ibus_indicator_text,
widget.xkb_indicator_text,
forced_num_cols = 1,
forced_num_rows = 2,
homogeneous = true,
expand = true,
layout = wibox.layout.grid
},
{ -- Left spacer
widget = wibox.widget.separator,
color = beautiful.color.transparent,
forced_width = beautiful.dpi(3)
},
layout = wibox.layout.align.horizontal,
},
layout = wibox.container.background,
}
-- Change background when mouse is over widget
widget.widget:connect_signal("mouse::enter", function(result)
widget.widget.bg = beautiful.color.bar.hover_bg
end)
widget.widget:connect_signal("mouse::leave", function(result)
widget.widget.bg = beautiful.color.transparent
end)
widget.update = function()
widget.ibus_indicator_text.markup = config.ibus.language_list[util.current_engine_index]["indicator_code"]
widget.xkb_indicator_text.markup = util.current_xkbmap
end
-- Update every 2 seconds, just in case.
widget.update_timer = gears.timer {
timeout = 2,
call_now = false,
autostart = true,
single_shot = false,
callback = function ()
util.get(widget.update)
end
}
return widget