Xsession is running on tty2
ps aux | grep -v awk | awk '/Xorg/ , gsub(".*Xorg", "") {print $1}' vt1 vt2
The problem is that DISPLAY variable by default is set to :1
echo $DISPLAY
:1
setting it to :0 cause the issue:
xset q
Invalid MIT-MAGIC-COOKIE-1 keyxset: unable to open display ":0"
Honestly, the main problem is powertop, that doesn't want to work with DISPLAY=:1, since:
sudo powertop -c
Invalid MIT-MAGIC-COOKIE-1 key/usr/bin/xset: unable to open display ":0"
It doesn't matter what display variable value is, the error is the same
UPDATE:
It seems that it is a bug of gdm, in case when gnome is running on x11 rather than Wayland. It runs two separated xsessions. But, for example Ubuntu somehow solved this issue, 18.04 has only single session using GNome + x11.
So, are there any workaround to set display number to zero for second real session , such that xset q will accept it ?
What is wrong with having the display variable being set to
:1
? This is a direct result of the fact that gdm is running on tty1 and a GNOME session is running on tty2. This is the default since a few Fedora releases and works the same no matter whether you are using the X11 or Wayland versions of gdm or the GNOME session.The display
:0
is probably owned by gdm and since the magic cookie is not readable by your user, you cannot connect there. This is not a bug, this is an important security feature.I do not see any reason why powertop might want to access the X server. This looks spooky.
Workaround: Can you switch to a tty, log in as root and run
powertop -c
there?