From 95e15674231d3c5f65060dea165362c6eaa10ed9 Mon Sep 17 00:00:00 2001 From: Arkhist Date: Tue, 23 Jul 2019 14:31:57 +0200 Subject: [PATCH] Add kbdlayout system (Alt-Shift to switch layout) --- rc.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/rc.lua b/rc.lua index b30cb7c..307a024 100644 --- a/rc.lua +++ b/rc.lua @@ -110,6 +110,16 @@ menubar.utils.terminal = terminal -- Set the terminal for applications that requ -- Keyboard map indicator and switcher mykeyboardlayout = awful.widget.keyboardlayout() +kbdlayout = {} +kbdlayout.cmd = "setxkbmap" +kbdlayout.layouts = { "fr", "us" } +kbdlayout.cur = 1 +kbdlayout.switch = function() + kbdlayout.cur = (kbdlayout.cur % #(kbdlayout.layouts)) + 1 + local t = kbdlayout.layouts[kbdlayout.cur] + os.execute( kbdlayout.cmd .. " " .. t ) +end + -- {{{ Wibar -- Create a textclock widget mytextclock = wibox.widget.textclock() @@ -388,7 +398,12 @@ globalkeys = gears.table.join( {description = "lua execute prompt", group = "awesome"}), -- Menubar awful.key({ modkey }, "p", function() menubar.show() end, - {description = "show the menubar", group = "launcher"}) + {description = "show the menubar", group = "launcher"}), + -- Keyboard layout switch + awful.key({ "Mod1" }, "Shift_L", function () kbdlayout.switch() end, + {description = "switch keyboard layout"}), + awful.key({ "Shift" }, "Alt_L", function () kbdlayout.switch() end, + {description = "switch keyboard layout"}) ) clientkeys = gears.table.join(