i3 Multiple Terminal Issue
I have a software issue on my laptop that I have not been able to resolve yet. I am using the i3 window manager, and the command that should open one terminal occasionally opens two terminals.
I have only experienced this issue on my laptop when running Arch Linux. I did not experience the issue when using NixOS or Debian on the same laptop, using the same configuration files. At this point, I am not sure if the issue is with i3, other software, or the hardware. I have searched i3 issues and /r/i3wm but have not been able to find any information about this issue.
$ i3 --version
i3 version 4.19.2 (2021-02-27) © 2009 Michael Stapelberg and contributors
$ pacman -Q xorg-server
xorg-server 1.20.11-1
$ uname -srv
Linux 5.12.2-arch1-1 #1 SMP PREEMPT Fri, 07 May 2021 15:36:06 +0000
Key Mapping
I use the Windows
key as my modifier key. My laptop only has a left Windows key,
identified as Super_L
with key code 0x85
.
$ xmodmap
xmodmap: up to 4 keys per modifier, (keycodes in parentheses):
shift Shift_L (0x32), Shift_R (0x3e)
lock Eisu_toggle (0x42)
control Control_L (0x25), Control_R (0x69)
mod1 Alt_L (0x40), Alt_R (0x6c), Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
$ grep '^set $mod' ~/.config/i3/config
set $mod Mod4
Pressing Win+Enter
is configured to open a terminal.
$ grep '^bindsym $mod+Return' ~/.config/i3/config
bindsym $mod+Return exec i3-sensible-terminal
Debugging
Logging can be enabled to help with debugging i3.
$ grep '^exec i3' ~/.xinitrc
exec i3 --shmlog-size=26214400
Without logging enabled, I experience the issue very frequently. I have not measured, but I estimate that the issue occurs with greater than 50% probability. With logging enabled, I experience the issue very infrequently. After enabling logging yesterday morning, it took 9 hours before I experienced the issue. After occurring once, it seemed to occur more frequently but still not as frequent as without logging enabled. My laptop has not been rebooted, and I have yet to experience this issue this morning.
Inspecting the logs, I find that i3 handles two KeyPress
events when the issue occurs. The logs are very verbose, but each
KeyPress
log is like the following:
... - ../src/handlers.c:handle_event:1271 - event type 2, xkb_base 85
... - ../src/key_press.c:handle_key_press:23 - KeyPress 36, state raw = 0x40
Here is the relevant i3 source:
Using xev
, I
confirmed that KeyPress
36 is indeed the enter key.
KeyPress event, serial 31, synthetic NO, window 0x4c00001,
root 0x6ac, subw 0x0, time 85317718, (387,292), root:(391,314),
state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
" XLookupString gives 1 bytes: (0d) "
" XmbLookupString gives 1 bytes: (0d) "
XFilterEvent returns: False
Thoughts
The fact that the issue does not occur consistently may indicate that it is caused by a race condition somewhere. The fact that enabling logging in i3 significantly reduces the frequency of occurrences may indicate that it is an i3 issue.
I have not ruled out a hardware issue, particularly because this laptop has had different problems with other operating systems. I tend to use laptops until they fail completely, but perhaps it is about time for a new laptop…
I have had this issue since installing Arch Linux on the laptop just over one year ago.
$ sudo dumpe2fs /dev/sda2 | grep 'Filesystem created:'
dumpe2fs 1.46.2 (28-Feb-2021)
Filesystem created: Sun May 3 16:22:37 2020
Resolving the issue has not been a priority, as it is only an annoyance, but I would really like to solve it. This laptop is my primary development system, however, so I am not willing to perform tests/experiments that would interrupt my normal usage. At this time, I do not want to switch to Wayland and Sway.