awesomewm/modules/keymap_popup/popup.lua

74 lines
1.5 KiB
Lua
Raw Normal View History

2022-09-30 22:13:33 -07:00
local ru_kb_img = conf_dir .. "modules/keymap_popup/ru_kb.svg"
local popup = {
width = awful.screen.focused().workarea.width * 0.8
}
popup.popup = awful.popup {
widget = wibox.widget {
wibox.widget {
image = ru_kb_img,
resize = true,
widget = wibox.widget.imagebox,
resize = true,
forced_width = popup.width,
forced_height = popup.width / 4,
},
valign = "center",
halign = "center",
margins = beautiful.dpi(20),
widget = wibox.container.margin
},
bg = "#00000000",
border_width = 0,
ontop = true,
placement = awful.placement.centered,
shape = gears.shape.rounded_rect,
hide_on_right_click = true,
visible = false
}
popup.grabber = awful.keygrabber {
stop_callback = function()
popup.popup.visible = false
end,
keypressed_callback = function(self, modifiers, modset)
popup.popup.visible = false
end,
export_keybindings = false,
}
function popup.hide()
popup.popup.visible = false
end
popup.popup:connect_signal("property::visible",
function(w)
if not w.visible then
w:disconnect_signal(
"button::press",
popup.hide
)
popup.grabber:stop()
else
w:connect_signal(
"button::press",
popup.hide
)
popup.grabber:start()
end
end
)
popup.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
}
return popup