Make keyboardlayout widget more robust (#1941)

I am not sure what exactly goes on in the below bug report, so this will
just paper over the problem. I still think that this patch is a good
idea even when it is not a proper fix, since keyboard layouts are
complicated and so this code should be robust and hard to break.

Fixes: https://github.com/awesomeWM/awesome/issues/1933
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2017-07-25 18:17:32 +02:00 committed by Daniel Hahler
parent 4f7444f1f4
commit acc012353d
1 changed files with 6 additions and 3 deletions

View File

@ -115,12 +115,15 @@ keyboardlayout.xkeyboard_country_code = {
-- Callback for updating current layout. -- Callback for updating current layout.
local function update_status (self) 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
-- Please note that the group number reported by xkb_get_layout_group -- 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. -- is lower by one than the group numbers reported by xkb_get_group_names.
text = (" " .. self._layout[self._current+1] .. " ") local name = self._layout[self._current+1]
if name then
text = " " .. name .. " "
end
end end
self.widget:set_text(text) self.widget:set_text(text)
end end