Fix single layout not appearing in the keyboardlayout widget (#1771)

Change indexing so that a keyboard map with a single group still gets
displayed in awful's keyboardlayout widget.

Signed-off-by: Quentin Minster <quentin@minster.io>
This commit is contained in:
Quentin Minster 2017-05-13 23:25:09 +02:00 committed by Daniel Hahler
parent 01e61079c3
commit 155c37e759
1 changed files with 5 additions and 6 deletions

View File

@ -118,7 +118,9 @@ local function update_status (self)
self._current = awesome.xkb_get_layout_group(); self._current = awesome.xkb_get_layout_group();
local text = "" local text = ""
if (#self._layout > 0) then if (#self._layout > 0) then
text = (" " .. self._layout[self._current] .. " ") -- Please note that the group number reported by xkb_get_layout_group
-- is lower by one than the group numbers reported by xkb_get_group_names.
text = (" " .. self._layout[self._current+1] .. " ")
end end
self.widget:set_text(text) self.widget:set_text(text)
end end
@ -238,13 +240,10 @@ local function update_layout(self)
return return
end end
if #layouts == 1 then if #layouts == 1 then
layouts[1].group_idx = 0 layouts[1].group_idx = 1
end end
for _, v in ipairs(layouts) do for _, v in ipairs(layouts) do
local layout_name = self.layout_name(v) self._layout[v.group_idx] = 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
end end
update_status(self) update_status(self)
end end