FreeSpacenav / spacenavd

Free user-space driver for 6-dof space-mice.
http://spacenav.sourceforge.net
GNU General Public License v3.0
274 stars 55 forks source link

failed to open X11 display #102

Closed axbycc-mark closed 5 months ago

axbycc-mark commented 5 months ago

I'm running Ubuntu 22.04.4

Following the FAQ and issue https://github.com/FreeSpacenav/spacenavd/issues/32, I have symlinked my ~/.Xauthority to /root/.Xauthority.

Now I see this error in the spnavd.log when running the daemon through sudo service spacenavd start.

Spacenav daemon v1.2-13-g3000236
reading config file: /etc/spnavrc
failed to open config file /etc/spnavrc: No such file or directory. using defaults.
found usb device [256f:c635]: "3Dconnexion SpaceMouse Compact" (/dev/input/event24) 
adding device (id: 0).
device name: 3Dconnexion SpaceMouse Compact
  Number of axes: 6 (0a 6r)
  Number of buttons: 2 (evdev offset: 256)
using device: 3Dconnexion SpaceMouse Compact (/dev/input/event24)
  device flags: swap y-z invert y-z
trying to open X11 display ":0.0"
   XAUTHORITY=/root/.Xauthority
failed to open X11 display ":0.0"
waiting for the X socket file to appear

The cube example fails with failed to connect to the space navigator daemon

However, when I manually start spacenavd with sudo ./spacenavd -d -vvvv, the cube example works and the daemon says the following.

Spacenav daemon v1.2-13-g3000236
reading config file: /etc/spnavrc
failed to open config file /etc/spnavrc: No such file or directory. using defaults.
Device detection, parsing /proc/bus/input/devices
found usb device [256f:c635]: "3Dconnexion SpaceMouse Compact" (/dev/input/event24) 
adding device (id: 0).
device name: 3Dconnexion SpaceMouse Compact
  Number of axes: 6 (0a 6r)
  Number of buttons: 2 (evdev offset: 256)
using device: 3Dconnexion SpaceMouse Compact (/dev/input/event24)
  device flags: swap y-z invert y-z
trying to open X11 display ":1"
   XAUTHORITY=/run/user/1000/gdm/Xauthority
Using XTEST to send key events

Then the cube example works. I think the issue is that the display needs to be ":1" instead of ":0.0" on my machine. I'm not sure if this option can be specified. I'm not experienced with X11 or Linux in general so hopefully you can give me some pointers here. Symlinking the /root/.Xauthority to /run/user/1000/gdm/Xauthority did not work either, as the display is still set to ":0.0" when running with the "service" method.

jtsiomb commented 5 months ago

The spacenavd daemon will connect to the X display specified in the DISPLAY environment variable, and fallback to the usual ":0.0" if DISPLAY is not set. To make it use display ":1", just set DISPLAY to that in the init script which starts the daemon. I'm not familiar with systemd, so I can't be more specific.

I assume that's all there is to it and there is no actual spacenavd bug here, so I'm closing the bug report. But feel free to continue posting if you think there's something I can do to help.