Implement using effective kitty config options for kittens

Also centralise reading of kitty options
This commit is contained in:
Kovid Goyal
2025-01-05 20:16:43 +05:30
parent 76ebc591db
commit 2d02ff1c5f
7 changed files with 31 additions and 27 deletions

View File

@@ -400,3 +400,19 @@ func ReloadConfigInKitty(in_parent_only bool) error {
}
return nil
}
func ReadKittyConfig(line_handler func(key, val string) error) error {
kitty_conf_path := ""
kp := os.Getenv("KITTY_PID")
if _, err := strconv.Atoi(kp); err == nil {
effective_config_path := filepath.Join(utils.CacheDir(), "effective-config", kp)
if unix.Access(effective_config_path, unix.R_OK) == nil {
kitty_conf_path = effective_config_path
}
}
if kitty_conf_path == "" {
kitty_conf_path = filepath.Join(utils.ConfigDir(), "kitty.conf")
}
cp := ConfigParser{LineHandler: line_handler}
return cp.ParseFiles(kitty_conf_path)
}