//go:build !windows package extsvc import ( "os" "os/exec" "path/filepath" "runtime" ) // DefaultTQSLPath finds TrustedQSL, or returns "" so the operator can point at // it by hand. // // PATH is asked FIRST, unlike the Windows side where two fixed install folders // are the whole story. On Linux tqsl comes from the distribution's package // manager, a Flatpak or a self-built copy, and each puts it somewhere // different; whichever one the operator installed is the one their shell finds. // The fixed list below is only for a desktop session that started without a // useful PATH. func DefaultTQSLPath() string { if p, err := exec.LookPath("tqsl"); err == nil && fileExists(p) { return p } candidates := []string{ "/usr/bin/tqsl", "/usr/local/bin/tqsl", "/var/lib/flatpak/exports/bin/org.arrl.tqsl", filepath.Join(os.Getenv("HOME"), ".local/share/flatpak/exports/bin/org.arrl.tqsl"), } if runtime.GOOS == "darwin" { candidates = append(candidates, "/Applications/TrustedQSL/tqsl.app/Contents/MacOS/tqsl") } for _, p := range candidates { if fileExists(p) { return p } } return "" } // DefaultStationDataPath returns TQSL's station_data location. // // ~/.tqsl is where the Unix build of TrustedQSL keeps its configuration. A // Flatpak install redirects it into the sandbox // (~/.var/app/org.arrl.tqsl/data/tqsl), so that is tried too — an operator on a // Flatpak TQSL otherwise sees an empty station-location list with nothing to // explain it. func DefaultStationDataPath() string { home, err := os.UserHomeDir() if err != nil || home == "" { return "" } for _, p := range []string{ filepath.Join(home, ".tqsl", "station_data"), filepath.Join(home, ".var", "app", "org.arrl.tqsl", "data", "tqsl", "station_data"), } { if fileExists(p) { return p } } // Nothing found: name the ordinary location anyway. The settings field then // shows the path TQSL would create on its first run, which is a better // starting point for the operator than an empty box. return filepath.Join(home, ".tqsl", "station_data") }