Language input not changing unless I restart i3 inplace

After some time has elapsed, at random, the second language input just stops working. If I need to change language, I have to restart i3 in place. Sometimes I might need to restart i3 in place multiple times until the language switcher responds and starts functioning again. How can I troubleshoot this?

I’m sure that your locale.gen is ok. With me as an example
grep -v '^#' /etc/locale.gen
pl_PL.UTF-8 UTF-8
en_US.UTF-8 UTF-8
hu_HU.UTF-8 UTF-8
sudo locale-gen has been run
I inserted into ~/.i3/config
exec_always --no-startup-id setxkbmap -layout hu,pl -variant ,qwertz -option grp:ctrl_alt_toggle
Should you need indicator in i3bar use i3blocks in config:

bar {
	status_command i3blocks -c ~/.i3/i3blocks.conf
###	i3bar_command i3bar
###	status_command i3status
	position bottom

for keyboard layouts switcher

see i3 config file

this needs xkblayout-state installed from the AUR:

AUR (en) - xkblayout-state-git



#!/usr/bin/env bash
KBD=$(/usr/bin/xkblayout-state print ‘%s’)
echo $KBD

btw Endeavouros i3-wm uses i3blocks

$mod+Shift+r (restart) also may help because I’ve encountered similar keyboard toggle problems in Mabox

It is. Here’s mine:
en_US.UTF-8 UTF-8
el_GR.UTF-8 UTF-8

my .i3/config has this in my case:
exec_always setxkbmap -layout us,gr exec_always setxkbmap -option 'grp:shifts_toggle'

I also have tray_output primary but I don’t have i3blocks. What I have is this:

> # Start i3bar to display a workspace bar (plus the system information i3status if available)
> bar {
>   i3bar_command i3bar
>   status_command i3status
>   position top
> ## please set your primary output first. Example: 'xrandr --output eDP1 --primary'
> tray_output primary
> # tray_output HDMI-1 
> # tray_output eDP1
>   bindsym button4 nop
>   bindsym button5 nop
> #   font xft:URWGothic-Book 11
>   strip_workspace_numbers no
>     colors {
>         background #222D31
>         statusline #F9FAF9
>         separator  #454947
> #                      border  backgr. text
>         focused_workspace  #F9FAF9 #16a085 #292F34
>         active_workspace   #595B5B #353836 #FDF6E3
>         inactive_workspace #595B5B #222D31 #EEE8D5
>         binding_mode       #16a085 #2C2C2C #F9FAF9
>         urgent_workspace   #16a085 #FDF6E3 #E5201D
>     }
> }

$mod+Shift+r (restart inplace) does indeed help, but the question remains: why does it have to happen in the first place?

I replaced setxkbmap with yours and was not able to reproduce the error.
I also met this feature. (this reminds me an old programming etude: Check whether the nth character of a string is G and if it is not replace with G – Simpler version overwrite it with G without testing. I would make two shortcuts. )
Edit: Yes, it’s annoying not knowing the reason of failure.

bindcode $mod+50 exec setxkbmap us 
bindcode $mod+62 exec setxkbmap gr

the first line is Super+Shift_L
the 2nd is Super+Shift_R
It is working – not relying on toggle state.