Scripts

Backup your app-settings.json file before modifying it
If there are errors, GridTracker2 replaces the settings with defaults ones, and your own settings are deleted! 

The Watchers can be copied to the app-settings.json file, when GridTracker2 is not running.  This can be done manually by using a text editor or running a script or batch file. 

In Linux terminal this can be done by running the command:

sed -i -ne '/"watchers": {/ {p; r YOUR_HOME/YOUR_DIRECTORY/DXWATCHER' -e ':a; n; /"YOUR_WATCHER": {/ {p; b}; ba}; p' ~/.config/GridTracker2/Ginternal/app-settings.json

In this command DXWATCHER is the name of the watcher file downloaded and YOUR_DIRECTORY the directory, where it is, and YOUR_HOME e.g. /home/YOUR_USERNAME.

YOUR_WATCHER is the name of a watcher created manually in GT2 and saved before running the above command (or the first one of the watchers created previously). The new DX watchers are written between the lines '"watchers": {' and '"YOUR_WATCHER": {' in app-settings.json.

copyWatchers.sh A script file to run the above command in Linux.

#!/bin/sh
if (ps cax | grep gridtracker2); then
  echo "Not copied. GridTracker2 is running."
else
  echo "GridTracker2 is not running."
  sed -i -ne '/"watchers": {/ {p; r YOUR_HOME/YOUR_DIRECTORY/DXWATCHER' -e ':a; n; /"YOUR_WATCHER": {/ {p; b}; ba}; p' YOUR_HOME/.config/GridTracker2/Ginternal/app-settings.json &
  wait
  echo "dxwatchers copied to app-settings.json"
fi

Replace YOUR_HOME, YOUR_DIRECTORY, DXWATCHER and YOUR_WATCHER with the relevant names. This script can be run as a crontab job in Linux.


In order to run unix commands in Windows, one can install Git (https://gitforwindows.org/)
It includes Git Bash, in which one can run Unix commands. Download a watcher file (DXWATCHER) to a directory (YOUR_DIRECTORY) and copy copyWatchers-win.sh to this directory. Run Git Bash terminal, move to YOUR_DIRECTORY, and run then the script file copyWatchers-win.sh.

copyWatchers-win.sh A script file to copy watchers to the app-settings.json in Windows.

#!/bin/sh
if (tasklist | grep GridTracker2.exe); then 
  echo "Not copied. GridTracker2 is running."
else
  echo "GridTracker2 is not running."
  sed -i -ne '/"watchers": {/ {p; r DXWATCHER' -e ':a; n; /"YOUR_WATCHER": {/ {p; b}; ba}; p' C:/Users/YOUR_USERNAME/AppData/Roaming/GridTracker2/Ginternal/app-settings.json &
wait
  echo "dxwatchers copied to app-settings.json"
fi


In Windows one can also use the files get_dxwatchers.bat and DXWatchers.exe. Then Git Bash is not required. Thanks to Bertel/SM6OES for providing these files.

Create one own watcher in GridTracker manually and give it a name starting with __ (or if where are already several watchers, edit them in GridTracker, and add __ to their names).

Copy get_dxwatchers.bat and DXWatchers.exe to the  working directory, e.g. C:\Users\YOUR_USERNAME\dxwatchers. Run get_dxwatchers.bat in the working directory and save watcher file(s) to the temp directory. Below dxwatchers4.txt is the watcher file used later. Change the variable USE, when using another file. Check the file app-settings-NEW.txt. If everything is okay, you can remove the comments from the end of the file, and let the watchers to be copied to app-settings.json automatically and start GridTracker2.


get_dxwatchers.bat A Windows batch file to download and copy the watchers to app-settings.json.

::
:: Just some params
::
set IN1=dxwatchers1.txt
set IN2=dxwatchers2.txt
set IN3=dxwatchers3.txt
set IN4=dxwatchers4.txt
set USE=dxwatchers4.txt
set OUT=dxwatchers-win.txt
set TMPPATH=C:\Users\YOUR_USERNAME\dxwatchers\tmp

::
Delete old files from the working directory
::
del %TMPPATH%\dxwatchers*.*

::pause

::
:: Open Firefox to manually download the files
::
"C:\Program Files\Mozilla Firefox\firefox.exe" https://www.oh4lbx.fi/dx-watchers/
pause

::
:: Copy app-settings.json to working directory and make a backup copy
::
copy /Y "C:\Users\YOUR_USERNAME\AppData\Roaming\GridTracker2\Ginternal\app-settings.json" .
copy /Y app-settings.json app-settings-BACKUP.json

::
:: Copy the manually downloaded files to working directory
::
copy /Y %TMPPATH%\%IN1% . 
copy /Y %TMPPATH%\%IN2% . 
copy /Y %TMPPATH%\%IN3% . 
copy /Y %TMPPATH%\%IN4% .  

::
:: Prepare one with correct input name for the .exe
::
copy /Y %USE% %OUT%

::
:: Run the conversion/creation program
::
.\DXWatchers.exe

::
:: Copy the result back to app-settings.json
::
::copy /Y app-settings-NEW.txt "C:\Users\YOUR_USERNAME\AppData\Roaming\GridTracker2\Ginternal\app-settings.json"
::pause

::
:: Start GridTracker
::
::set ELECTRON_NO_ATTACH_CONSOLE=true

::
:: Change the path, if GridTracker2.exe is somewhere else.
::
::"C:\Users\YOUR_USERNAME\AppData\Local\Programs\GridTracker2\GridTracker2.exe"


If one wants to copy watchers to GridTracker2 as a scheduled task in Windows, it can be done by starting copyWatchers-win.sh from a batch file (Git Bash is required) and by adding runBashcopytoGT.bat to Scheduled Tasks.

runBashcopytoGT.bat A Windows batch file to copy the watchers.

@ECHO OFF
cmd /c ""C:\Program Files\Git\bin\bash.exe" --login -i -- C:\Users\YOUR_PATH\copyWatchers-win.sh" 


tail_log.py A python script to show the latest QSOs from wsjtx.log in terminal.

#!/usr/bin/python3.11
import sys
import re
while 1:
try:
    line = sys.stdin.readline()
    l = line.split(',')
except KeyboardInterrupt:
    break
if not line:
    break
print(l[4], " \t", l[5][:4], "\t", l[8], l[9], l[7], l[1], l[0], l[6])

This script can be run in Linux terminal by the command (mark first the script as executable (chmod +x tail_log.py): 
tail -f ~/.local/share/WSJT-X/wsjtx.log | ~/.local/share/WSJT-X/tail_log.py
The display is updated always, when a QSO is logged in WSJT-X. The number of lines displayed at the beginning can be changed by adding the option "-n NUM", e.g. tail -n 20 -f ... The default is 10.