Scenario: Getting KDE Nightlight and other Geoclue dependent things working from GPS . It requires Geoclue which can read NMEA data. GPSD can output NMEA directly, but you have to turn off JSON data to do it. If you just want NMEA, this might something to look into. If you want both NMEA and JSON output, GPSD comes with a tool to create a NMEA feed from it's JSON so you can have both.
Method: use gpspipe which comes with GPSD to translate the JSON to NMEA, and socat to create a Unix socket to feed that data into Geoclue. Put it in a loop to hopefully make it so it recovers.
install (review GSPD use flags and configure uses if needed prior):
Code: Select all
emerge -av net-misc/socat sci-geosciences/gpsd app-misc/geoclue/usr/local/bin/nmeasource
Code: Select all
#!/bin/bash
while true; do
logger -t geoclue-nmea "starting gpspipe socat listener"
gpspipe -r | socat - UNIX-LISTEN:/run/gpsd-nmea.sock,fork,perm=666
rm /run/gpsd-nmea.sock
logger -t geoclue-nmea "error restarting gpspipe socat listener"
sleep 5
done
Create an OpenRC init script to start it at boot:
/etc/init.d/nmeasource
Code: Select all
#!/sbin/openrc-run
name="$RC_SVCNAME"
description="Geoclue gpsd shim"
supervisor="supervise-daemon"
command="/usr/local/bin/nmeasource"
depend() {
need gpsd
after gpsd
before geoclue
}
Code: Select all
sudo chmod +x /etc/init.d/nmeasource
sudo chmod +x /usr/local/bin/nmeasource
sudo rc-update add gpsd default
sudo rc-update add nmeasource default
sudo rc-update add geoclue default
Configure Geoclue to read NMEA:
Make sure /etc/geoclue/geoclue.conf has this section:
Code: Select all
[network-nmea]
enable=true
nmea-socket=/run/gpsd-nmea.sock
From a root terminal run:
Code: Select all
killall geoclue && G_MESSAGES_DEBUG=all /usr/libexec/geoclueFurther semirelated. If your GPS doesn't work very well it might be in power saving mode. It goes into the reeds from that because how you fix that depends on the device. This works for my device, for example:
Code: Select all
//reset to default config
ubxtool --preset RESET
//set serial port speed
ubxtool --setspeed 9600 --file /dev/ttyAMA0
//turn of power management
ubxtool --preset CFG-PMS,0
//output twice a second
ubxtool --preset CFG-RATE,500,1