From acc012353d03ad2c1e0783e19fe5f1f1c6a4c798 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Tue, 25 Jul 2017 18:17:32 +0200 Subject: [PATCH] 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 --- lib/awful/widget/keyboardlayout.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/awful/widget/keyboardlayout.lua b/lib/awful/widget/keyboardlayout.lua index ced2543ef..0a885a360 100644 --- a/lib/awful/widget/keyboardlayout.lua +++ b/lib/awful/widget/keyboardlayout.lua @@ -115,12 +115,15 @@ keyboardlayout.xkeyboard_country_code = { -- Callback for updating current layout. local function update_status (self) - self._current = awesome.xkb_get_layout_group(); + self._current = awesome.xkb_get_layout_group() local text = "" - if (#self._layout > 0) then + if #self._layout > 0 then -- 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] .. " ") + local name = self._layout[self._current+1] + if name then + text = " " .. name .. " " + end end self.widget:set_text(text) end