Allow GUI applications run by root user to connect to X server

A quick fix to run QT application (e.g. Wireshark) as root

Wayland logo. Souce: wikimedia.org
Wayland logo. Souce: wikimedia.org

Recently I had an annoying problem running Wireshark as root user on Fedora 27 (Wayland + Gnome 3.26).
I was getting following error:

sudo wireshark
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QXcbConnection: Could not connect to display
Aborted (core dumped)

To fix this, you need to add root user to the list of users allowed to make connections to the X server.

xhost si:localuser:root

That’s it. From now on, you shouldn’t have any problems running GUI applications by root user.

For more info on debuging Wayland problems please refer to Fedora’s wiki page

PS. xprop tool, described in the aforementioned wiki page, has a cool feature to display application icon as ASCII art :) Here’s for example Vivaldi’s icon:


	  ░▒▒▒▒▒▒▒▒▒▒░
	 ▒▒▒▒▒▒▒▒▒▒▒▒▒▒
	░▒▒▒▒▒▒▒▒▒▒▒▒▒▒░
	▒▒▒░░▒▒▒▒▒░░▒▒▒▒
	▒▒▒  ░▒▒▒▒  ░▒▒▒
	▒▒░   ▒▒▒▒  ░▒▒▒
	▒▒▒   ░▒▒▒  ▒▒▒▒
	▒▒▒░   ░▒░ ░▒▒▒▒
	▒▒▒▒       ▒▒▒▒▒
	▒▒▒▒░     ░▒▒▒▒▒
	▒▒▒▒▒     ▒▒▒▒▒▒
	▒▒▒▒▒▒   ▒▒▒▒▒▒▒
	▒▒▒▒▒▒░░░▒▒▒▒▒▒▒
	░▒▒▒▒▒▒▒▒▒▒▒▒▒▒░
	 ▒▒▒▒▒▒▒▒▒▒▒▒▒▒
	  ░▒▒▒▒▒▒▒▒▒▒░