Friday, November 26, 2021

 Strava GPX export and how to fix times

If you are on Strava you can usually not easily download gpx track from your friends without being a subscriber. There exits browser extensions fro chrome or firefox that can help you with that.

What I noticed however is that the timestamps within such exported track are based on Unix epoch.

In addition the whole file usually comes without end-of-line characters.

To fix the latter first you can use gpsbabel and use 'gpx' for input  as well as for output type. This literally will reformat the gpx to make it better readable in you favorite editor (mine is emacs btw).

$ gpsbabel -i gpx -f 1234.gpx  -o gpx -F 1234_babel1.gpx

I also found that the first trackpoint was without a timestamp, so you might want to fix it or just delete this trackpoint.

As an example it might look like this:

      <trkpt lat="50.144884000" lon="5.718563000">

As you can see the time starts at unix epoch (Zulu).

To fix this note down the real ZULU time when the run happend (in Strava that is shown for that activity). Let say that run started at 6:00 PM on Friday, February 21, 2020 then we can get the epoch offset (seconds after epoch) like this:

$ date --date='02/21/2020 17:00:00Z' +"%s"

Now use gpsbabel to add the offset, of course you can directly work on the original file skipping the first step above to just re-write the same file with newlines:

$ ./gpsbabel/gpsbabel -i gpx -f 1234_babel1.gpx -x track,move=+1582304400s  -o gpx -F 1234_babel2.gpx 

... so why you want to do this??? In my case I wanted to create an animation with two gpx tracks where one was my run and the other was from someone else (being on Strava as well) so to correlate the times we need to fix either my track (since it has correct timestamps, we could normalize to epoch) or do what is described here.

Then you use  to generate a video file like this  one:  LegendsTrail_GPX-Animation.mp4

Tuesday, October 5, 2021

 # OpenRazer on RedHat 8.4

## building rpm

Basically follow the steps for Fedora listed here:


sudo dnf install rpm-build rpmdevtools


cd ~/rpmbuild/SPECS

curl -O

# To build from custom sources, pause here to edit openrazer.spec:

# Replace the line with "#define gitcommit" with "%define gitcommit $yourcommit"

# Optionally you will have to edit the first "Source0:" line to point to a different repository than openrazer/openrazer.

spectool -g -R openrazer.spec

sudo dnf -y builddep openrazer.spec

rpmbuild -bb openrazer.spec

sudo dnf install ../RPMS/noarch/*.rpm


I have python 3.6 amd 3.8 installed, rpmbuild took wrong version in order to fix this add this define to override python_sitelib:

%define python3_sitelib /usr/lib/python3.8/site-packages

in addition I used the latest git commit hash from main (check yourself):
#define gitcommit 7c353f9c8f1439bce5396218331c412eae0c2563

I could not find a python3-daemonize package in redhat yum repository. But that does not matter, actually I  think I do not need the daemon anyway. Most frontends only require the driver. So you could remove that requirement if you want to get it installed then install daemonize via pip3 for example.


I created this specfile to build xautomation rpm (again I do not make use of it ... but at that time thought I might require the dependency)

# use spectool to download source:
# spectool -g -R xautomation.spec

%define python3_sitelib /usr/lib/python3.8/site-packages

%define debug_package %{nil}

Name: xautomation

Version: 1.09

Release: 4%{?dist}

Summary: Controls X from the command line and does "visual scraping".

License: GPL-2.0


BuildArch: x86_64

Requires: libXtst-devel


Controls X from the command line and does "visual scraping".

%autosetup -n xautomation-%{version}

./configure --prefix=$RPM_BUILD_ROOT/usr

make install




find keyboard


[ -d /sys/bus/hid/drivers/razerkbd ] || exit 1

device=$(find -H /sys/bus/hid/drivers/razerkbd/0003\:1532\:0241.*/ -type f -name device_type)

device_type=$(cat $device)

device=$(echo ${device%/*})

if [ "Razer BlackWidow 2019" = "$device_type" ]; then

    echo "Keyboard found at: $device"


    echo "No Razer Blackwidow found!"

    exit 2


set effects

# echo -n -e "\x03\x00\xFF\xFF" > $device/matrix_effect_reactive
if [ -z "$matrix" ]; then
    echo "bye"

case $matrix in
    echo "setup wave pattern"
    echo -n "1" > $device/matrix_effect_wave
    echo "setup starlight pattern"
    if [ -z "$speed" ] || [ -z "$color" ]; then
echo "no speed and color provided using: \"\x03\x00\xFF\xFF\""
echo -n -e "\x03\x00\xFF\xFF" > $device/matrix_effect_reactive
#exit 3
    echo "setup reactive effect: \"$speed$color\""
    echo -n -e "$speed$color" > $device/matrix_effect_reactive
#   *)
#     ;;