From cec2462802460c3423e316ae2fd4b38dedf7cd86 Mon Sep 17 00:00:00 2001 From: Mark Date: Fri, 30 Sep 2022 22:13:33 -0700 Subject: [PATCH] Added basic keymap popup --- config-template.lua | 1 + modules/keymap_popup/init.lua | 15 + modules/keymap_popup/popup.lua | 74 ++++ modules/keymap_popup/ru_kb.svg | 739 +++++++++++++++++++++++++++++++++ 4 files changed, 829 insertions(+) create mode 100644 modules/keymap_popup/init.lua create mode 100644 modules/keymap_popup/popup.lua create mode 100644 modules/keymap_popup/ru_kb.svg diff --git a/config-template.lua b/config-template.lua index 8069d16..33699c8 100755 --- a/config-template.lua +++ b/config-template.lua @@ -5,6 +5,7 @@ config.backlight = { enabled = false } config.simple_widgets = { enabled = true } config.launcher = { enabled = true } config.screenshot = { enabled = true } +config.keymap_popup = { enabled = true } config.core = { wallpaper = "/home/assets/wallpapers/Themed/Stellaris/Gigapixel/City.png", diff --git a/modules/keymap_popup/init.lua b/modules/keymap_popup/init.lua new file mode 100644 index 0000000..84408f6 --- /dev/null +++ b/modules/keymap_popup/init.lua @@ -0,0 +1,15 @@ +local popup = require("modules.keymap_popup.popup") + +return { + keybinds = gears.table.join( + awful.key( {"Mod4"}, "0", + function() + popup.popup.visible = not popup.popup.visible + end, + { + description = "Show russian keyboard layout", + group = "Desktop" + } + ) + ) +} diff --git a/modules/keymap_popup/popup.lua b/modules/keymap_popup/popup.lua new file mode 100644 index 0000000..e957319 --- /dev/null +++ b/modules/keymap_popup/popup.lua @@ -0,0 +1,74 @@ +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 \ No newline at end of file diff --git a/modules/keymap_popup/ru_kb.svg b/modules/keymap_popup/ru_kb.svg new file mode 100644 index 0000000..3353284 --- /dev/null +++ b/modules/keymap_popup/ru_kb.svg @@ -0,0 +1,739 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Ё + Й + Ц + У + К + Е + Н + Г + Ш + Щ + З + Х + Ъ + Э + Ж + Д + Л + О + Р + П + А + В + Ы + Ф + Я + Ч + С + М + И + Т + Ь + Б + Ю + Tab + Caps + Lock + Shift + Shift + Enter + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 0 + - + = + \ + + ! + " + + ; + % + : + ? + * + ( + ) + _ + + + / + . + , + + + +