Skip to content

Commit f2e3f1e

Browse files
authored
fix: ensure correct config exposes to status command (#8)
1 parent 286c7b1 commit f2e3f1e

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

cmd/govim/main.go

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"image"
66
"os"
77
"os/signal"
8+
"path/filepath"
89
"strings"
910
"syscall"
1011
"time"
@@ -35,7 +36,9 @@ const (
3536

3637
// App represents the main application
3738
type App struct {
38-
config *config.Config
39+
config *config.Config
40+
// ConfigPath holds the path the daemon was started with (if any)
41+
ConfigPath string
3942
logger *zap.Logger
4043
hotkeyManager *hotkeys.Manager
4144
hintGenerator *hints.Generator
@@ -974,10 +977,27 @@ func (a *App) handleIPCCommand(cmd ipc.Command) ipc.Response {
974977
return ipc.Response{Success: true, Message: "mode set to idle"}
975978

976979
case "status":
977-
statusData := map[string]interface{}{
980+
cfgPath := a.ConfigPath
981+
if cfgPath == "" {
982+
// Fallback to the standard config path if daemon wasn't started
983+
// with an explicit --config
984+
cfgPath = config.GetConfigPath()
985+
}
986+
987+
// Expand ~ to home dir and resolve relative paths to absolute
988+
if strings.HasPrefix(cfgPath, "~") {
989+
if home, err := os.UserHomeDir(); err == nil {
990+
cfgPath = filepath.Join(home, cfgPath[1:])
991+
}
992+
}
993+
if abs, err := filepath.Abs(cfgPath); err == nil {
994+
cfgPath = abs
995+
}
996+
997+
statusData := map[string]any{
978998
"enabled": a.enabled,
979999
"mode": a.getModeString(),
980-
"config": config.GetConfigPath(),
1000+
"config": cfgPath,
9811001
}
9821002
return ipc.Response{Success: true, Data: statusData}
9831003

@@ -1051,6 +1071,9 @@ func LaunchDaemon(configPath string) {
10511071
fmt.Fprintf(os.Stderr, "Error creating app: %v\n", err)
10521072
os.Exit(1)
10531073
}
1074+
// Record the config path the daemon was started with so status can report
1075+
// the same path (if provided via --config)
1076+
app.ConfigPath = configPath
10541077
globalApp = app
10551078

10561079
// Start app in goroutine

0 commit comments

Comments
 (0)