From 18799665569cf136a40f7b722d88259dd97ac9b1 Mon Sep 17 00:00:00 2001 From: Abdo Roig-Maranges Date: Wed, 30 Mar 2016 14:32:21 +0200 Subject: [PATCH 1/3] handle layout names like us(altgr-intl) --- lib/awful/widget/keyboardlayout.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/awful/widget/keyboardlayout.lua b/lib/awful/widget/keyboardlayout.lua index b3b837626..2eb407663 100644 --- a/lib/awful/widget/keyboardlayout.lua +++ b/lib/awful/widget/keyboardlayout.lua @@ -214,7 +214,7 @@ function keyboardlayout.get_groups_from_group_names(group_names) end if section then - section = string.gsub(section, "%(([%w_]+)%)", "%1") + section = string.gsub(section, "%(([%w-_]+)%)", "%1") end table.insert(layout_groups, { vendor = vendor, From cb46f093615281818181fc327a86107b59e6b4bc Mon Sep 17 00:00:00 2001 From: Abdo Roig-Maranges Date: Wed, 30 Mar 2016 14:37:18 +0200 Subject: [PATCH 2/3] make keyboard layout naming function easily overridable --- lib/awful/widget/keyboardlayout.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/awful/widget/keyboardlayout.lua b/lib/awful/widget/keyboardlayout.lua index 2eb407663..f9142b894 100644 --- a/lib/awful/widget/keyboardlayout.lua +++ b/lib/awful/widget/keyboardlayout.lua @@ -241,10 +241,7 @@ local function update_layout(self) layouts[1].group_idx = 0 end for _, v in ipairs(layouts) do - local layout_name = v.file - if v.section ~= nil then - layout_name = layout_name .. "(" .. v.section .. ")" - end + local layout_name = self.layout_name(v) -- Please note that numbers of groups reported by xkb_get_group_names -- is greater by one than the real group number. self._layout[v.group_idx - 1] = layout_name @@ -260,7 +257,13 @@ function keyboardlayout.new() self.widget = widget - update_layout(self); + self.layout_name = function(v) + local name = v.file + if v.section ~= nil then + name = name .. "(" .. v.section .. ")" + end + return name + end self.next_layout = function() self.set_layout((self._current + 1) % (#self._layout + 1)) @@ -275,6 +278,8 @@ function keyboardlayout.new() awesome.xkb_set_layout_group(group_number); end + update_layout(self); + -- callback for processing layout changes capi.awesome.connect_signal("xkb::map_changed", function () update_layout(self) end) From 20bfcdc614699a73bff62233c15f44917ad8c0a9 Mon Sep 17 00:00:00 2001 From: Abdo Roig-Maranges Date: Wed, 30 Mar 2016 17:03:28 +0200 Subject: [PATCH 3/3] add test for us(altgr+intl) keyboard layout --- spec/awful/keyboardlayout_spec.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/awful/keyboardlayout_spec.lua b/spec/awful/keyboardlayout_spec.lua index ae168e9f8..e2a5c9660 100644 --- a/spec/awful/keyboardlayout_spec.lua +++ b/spec/awful/keyboardlayout_spec.lua @@ -23,6 +23,9 @@ describe("awful.widget.keyboardlayout get_groups_from_group_names", function() { file = "de", group_idx = 1 }, { file = "jp", group_idx = 1 } }, + ["us(altgr-intl)"] = { + { file = "us", group_idx = 1, section = "altgr-intl" } + }, -- possible eight variations of a single term ["de"] = { { file = "de", group_idx = 1 }