feat: Added --profile argument to start OpsLog on specific profile

This commit is contained in:
2026-06-20 19:47:22 +02:00
parent 4b5e2e0b72
commit 260172cd6d
2 changed files with 42 additions and 0 deletions
+17
View File
@@ -383,6 +383,7 @@ type App struct {
cwStop chan struct{} // stops the CW decoder capture loop; nil when off
cwDecoder *cwdecode.Decoder // live decoder (for retargeting the pitch)
cwPitchHz int // manual pitch override (0 = auto / follow Flex)
startupProfile string // --profile <name> from the command line (activate at startup)
dvkRecSlot int // slot currently being recorded (DVKStartRecord → DVKStopRecord)
dvkPttKeyed bool // we keyed PTT for a voice message; unkey when it ends
pttMu sync.Mutex
@@ -613,6 +614,22 @@ func (a *App) startup(ctx context.Context) {
if err != nil {
fmt.Println("OpsLog: EnsureDefault profile:", err)
}
// A "--profile <name>" command-line argument selects which profile to start
// on (so a desktop shortcut can launch OpsLog straight into F4BPO or TM2Q).
// Match by name, case-insensitive; activate it before any per-profile wiring.
if want := strings.TrimSpace(a.startupProfile); want != "" {
if list, lerr := a.profiles.List(a.ctx); lerr == nil {
for _, p := range list {
if strings.EqualFold(p.Name, want) {
if serr := a.profiles.SetActive(a.ctx, p.ID); serr == nil {
active = p
fmt.Printf("OpsLog: started on profile %q (from --profile)\n", p.Name)
}
break
}
}
}
}
a.settings.SetProfile(active.ID)
a.awardRefs = awardref.NewRepo(conn)
a.qslTemplates = qslcard.NewRepo(conn)