diff --git a/app.go b/app.go index 402be55..397cd25 100644 --- a/app.go +++ b/app.go @@ -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 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 " 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) diff --git a/main.go b/main.go index 088dd97..5797850 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,8 @@ package main import ( "embed" + "os" + "strings" "github.com/wailsapp/wails/v2" "github.com/wailsapp/wails/v2/pkg/options" @@ -11,9 +13,32 @@ import ( //go:embed all:frontend/dist var assets embed.FS +// profileArg extracts a profile name from the command line. Accepts +// "--profile NAME", "--profile=NAME", "-profile NAME", "-p NAME" so a desktop +// shortcut can launch OpsLog straight into a given profile (e.g. F4BPO / TM2Q). +func profileArg(args []string) string { + for i := 0; i < len(args); i++ { + a := args[i] + switch { + case a == "--profile" || a == "-profile" || a == "-p": + if i+1 < len(args) { + return strings.TrimSpace(args[i+1]) + } + case strings.HasPrefix(a, "--profile="): + return strings.TrimSpace(strings.TrimPrefix(a, "--profile=")) + case strings.HasPrefix(a, "-profile="): + return strings.TrimSpace(strings.TrimPrefix(a, "-profile=")) + case strings.HasPrefix(a, "-p="): + return strings.TrimSpace(strings.TrimPrefix(a, "-p=")) + } + } + return "" +} + func main() { // Create an instance of the app structure app := NewApp() + app.startupProfile = profileArg(os.Args[1:]) // Create application with options err := wails.Run(&options.App{