I have an application which makes use of a 3dconnexion space mouse. It works fine when using the spacenavd
daemon however I'm having issues getting the daemon to run at boot or as a service.
$ sudo service spacenavd start
in /var/log/spnavd.log
Spacenav daemon 0.5
failed to open config file /etc/spnavrc: No such file or directory. using defaults.
Device detection, parsing /proc/bus/input/devices
using device: /dev/input/event5
device name: 3Dconnexion SpaceNavigator
trying to open X11 display ":0.0"
XAUTHORITY=/root/.Xauthority
No protocol specified
No protocol specified
failed to open X11 display ":0.0"
waiting for X socket file to appear
When I run the system V init script however, I don't have any issues:
$ sudo /etc/init.d/spacenavd start
in /var/log/spnavd.log
Spacenav daemon 0.5
failed to open config file /etc/spnavrc: No such file or directory. using defaults.
Device detection, parsing /proc/bus/input/devices
using device: /dev/input/event5
device name: 3Dconnexion SpaceNavigator
trying to open X11 display ":0"
XAUTHORITY=/home/sam/.Xauthority
The problem is that I need the daemon to start from boot instead of launching it manually which requires sudo access.
Edit (suggestion from muru)
I made the following upstart script
description "Spacenavd upstart script. Starts after lightdm to allow for binding with the Xorg server"
author "Samuel Charreyron"
start on started lightm
stop on shutdown
pre-start script
echo "Starting spacenavd daemon"
end script
script
env DISPLAY=:0.0
exec /usr/sbin/spacenavd -v -d 2> /var/log/spnavd.log
end script
pre-stop script
echo "Stopping spacenavd daemon"
# detect daemon's process id
pid=`cat /var/run/spnavd.pid 2>/dev/null`
if [ $? != 0 ]; then
pid=`ps -e | grep spacenavd | awk '{ print $1 }'`
if [ -z "$pid" ]; then
echo 'spacenavd daemon is not running, nothing to do.'
exit 1
fi
fi
kill $pid
end script
I see that spacenavd cannot connect to the Xorg server. In fact, any upstart script that is run by root seems unable to use Xorg. How can I do so, since spacenavd needs sudo access to the USB devices?
No comments:
Post a Comment