Cannot open new windows on network change
I cannot open new windows when I change networks. I spent some time debugging it and I think it stems from the fact that I have a transient hostname(I believe that the kernel generates the hostname based on the currently connected network). This stemmed from the fact that when I set my hostname to 'localhost' when installing on various distros, this turned out to be a keyword and something decided that I wanted a transient hostname.
I hopped distros a lot and this issue would pop up on Manjaro and Xubuntu. I'm currently on Fedora and this issue occurs.
After some bug hunting and research I found the following quote from the hostnamectl manpage
If a static hostname is set, and is valid (something other than localhost), then the transient hostname is not used.
This involves x authorization using hostname and assuming it is static and won't change during normal usage.
One mitigation is that people just don't use transient hostnames or have a warning against using 'localhost' as a hostname since it may or may not break everything depending on the distro or may cause issues later.
Another mitigation is that since xserver is the common denominator, it would make more sense to fix it here to handle the case that a user is using a transient hostname.
Replicating the issue
This bug is very inconsistent, but on fedora I can replicate the issue by using
sudo hostnamectl set-hostname localhost
and then changing networks(it only works sometimes depending on the network).
For reference my hostname would become sometimes localhost.localdomain and at my university it would sometimes have my ip address as part of the hostname followed by a domain name or something.
Finding the bug
Finding the cause was really hard because the bug was super inconsistent and I honestly thought closing my laptop or locking my computer was sometimes breaking my i3 keybindings when it was really the fact that I was moving to another location at my university whenever I closed my laptop and then I thought that maybe NetworkManager was broken when it was really just the fact that I named my computer something that nobody thought someone would name their computer leading my computer to have an identity crisis that xserver wanted no part in.
Other instances of this issue
Googling 'xserver transient hostname' yielded the following
- X server randomly stops accepting new connections
- Static hostname changed by nm-applet
- After resuming from hibernation no GUI applications can connect to X
however googling the symptoms('cannot open new windows i3') fails to produce useful results.
The thing they all have in common is the fact that tracing the root cause of this issue is kinda hard for mere mortals since the symptoms are all very diverse especially when a bug was following me from distro to distro since the source of my issue was from me naming my computer localhost all of the times.
naming your computer localhost breaks xserver whenever you change networks.