Ariver
2026-05-18 8f11df460a247dfcaafd84ce3046605724d11998
VoiceSnapGo/internal/config/config.go
@@ -7,9 +7,15 @@
   "voicesnap/internal/paths"
)
const (
   HotkeyModeTap  = "tap"
   HotkeyModeHold = "hold"
)
// Config holds the application configuration, compatible with the WPF version's config.json.
type Config struct {
   HotkeyVK                 int    `json:"HotkeyVK"`
   HotkeyMode               string `json:"HotkeyMode"`
   AutoHide                 bool   `json:"AutoHide"`
   SoundFeedback            bool   `json:"SoundFeedback"`
   HideDockIcon             bool   `json:"HideDockIcon"`
@@ -25,6 +31,7 @@
func Default() *Config {
   return &Config{
      HotkeyVK:                 0xA5, // Right Alt
      HotkeyMode:               HotkeyModeHold,
      AutoHide:                 true,
      SoundFeedback:            true,
      HideDockIcon:             true,
@@ -55,9 +62,19 @@
   if err := json.Unmarshal(data, cfg); err != nil {
      return nil, err
   }
   cfg.HotkeyMode = NormalizeHotkeyMode(cfg.HotkeyMode)
   return cfg, nil
}
func NormalizeHotkeyMode(mode string) string {
   switch mode {
   case HotkeyModeTap, HotkeyModeHold:
      return mode
   default:
      return HotkeyModeHold
   }
}
// Save writes the config to disk.
func Save(cfg *Config) {
   if err := paths.Ensure(); err != nil {