2019-08-13 23:58:50 +02:00
|
|
|
local awful = require("awful")
|
|
|
|
|
|
|
|
local hotkey = require("simple/core/hotkey")
|
|
|
|
|
|
|
|
local config = require("config")
|
|
|
|
|
|
|
|
|
|
|
|
local widget = awful.widget.keyboardlayout()
|
|
|
|
local layouts = config.widgets.keyboard_layout.layouts
|
|
|
|
|
|
|
|
local current_layout_index = 1
|
|
|
|
function switchLayout()
|
|
|
|
current_layout_index = (current_layout_index % #(layouts)) + 1
|
2021-04-08 12:43:56 +02:00
|
|
|
os.execute(config.widgets.keyboard_layout.layout_switch_command .. " \"" .. layouts[current_layout_index] .. "\"")
|
2019-08-13 23:58:50 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
|
|
|
widget = widget,
|
|
|
|
switch = switchLayout,
|
|
|
|
getKeys = function(config)
|
|
|
|
return hotkey.make(config.switch, switchLayout,
|
|
|
|
{ description = "switch keyboard layout" }),
|
|
|
|
hotkey.make(config.switch_alt, switchLayout,
|
|
|
|
{ description = "switch keyboard layout (alternative)" })
|
|
|
|
end
|
2021-04-08 12:43:56 +02:00
|
|
|
}
|