local language = {} language.language_list = conf.ibus_language_list language.widget = wibox.widget { homogeneous = false, vertical_homogeneous = true, horizontal_homogeneous = false, vertical_spacing = beautiful.dpi(10), horizontal_spacing = beautiful.dpi(0), min_cols_size = beautiful.dpi(20), min_rows_size = beautiful.dpi(20), layout = wibox.layout.grid } for k, l in pairs(language.language_list) do l["widget_checkbox"] = wibox.widget { checked = false, border_width = beautiful.dpi(3), paddings = beautiful.dpi(4), margins = beautiful.dpi(5), color = beautiful.color.bar.active, border_color = beautiful.color.bar.inactive, widget = wibox.widget.checkbox, forced_height = beautiful.dpi(30), forced_width = beautiful.dpi(30), shape = gears.shape.circle, } language.widget:add_widget_at(l["widget_checkbox"], k, 1, 1, 1) language.widget:add_widget_at(wibox.widget { markup = "" .. l["title"] .. "", align = "left", valign = "center", font = "Comfortaa 23", widget = wibox.widget.textbox }, k, 2, 0, 1) end language.next = function() if (language.popup.visible) then wrapper.ibus.next(function() language.update_checks() end) else language.update_checks() end language.show_popup() end language.set = function(idx) debug_message(idx) wrapper.ibus.set(idx, function() language.update_checks() end) language.show_popup() end language.update_checks = function() for _, l in pairs(language.language_list) do l["widget_checkbox"].checked = (wrapper.ibus.current_engine == l["ibus_engine"]) end end language.show_popup = function() language.popup.screen = awful.screen.focused() language.popup.visible = true language.popup_timer:again() end language.popup = awful.popup { widget = { { language.widget, margins = 10, widget = wibox.container.margin }, bg = "#000000", opacity = 1, widget = wibox.container.background }, border_color = "#000000", border_width = 0, opacity = 1, type = "menu", ontop = true, visible = false, hide_on_right_click = true, shape = gears.shape.rounded_rect, placement = function(d) return awful.placement.centered(d, { honor_workarea = true }) end, } language.popup_timer = gears.timer { timeout = 1, autostart = false, call_now = false, single_shot = true, callback = function() language.popup.visible = false end } return language