config: json -> yaml

parent 41a62e06
......@@ -6,7 +6,6 @@ import (
"ximperconf/hyprland"
"context"
"encoding/json"
"fmt"
"os"
"os/exec"
......@@ -15,6 +14,7 @@ import (
"github.com/fatih/color"
"github.com/urfave/cli/v3"
"gopkg.in/yaml.v3"
)
func processProfile(prof Profile, dryRun bool, res *Result) {
......@@ -215,9 +215,13 @@ func loadConfig(path string) (*Config, error) {
if err != nil {
return nil, err
}
var cfg Config
err = json.Unmarshal(data, &cfg)
return &cfg, err
if err := yaml.Unmarshal(data, &cfg); err != nil {
return nil, err
}
return &cfg, nil
}
func expandPath(path, name string) string {
......
package create
type CopyEntry struct {
Src string `json:"src"`
Dest string `json:"dest"`
Src string `yaml:"src"`
Dest string `yaml:"dest"`
}
type LinkEntry struct {
Apps []string `json:"apps,omitempty"`
App string `json:"app,omitempty"`
Sys string `json:"sys"`
User string `json:"user"`
Apps []string `yaml:"apps,omitempty"`
App string `yaml:"app,omitempty"`
Sys string `yaml:"sys"`
User string `yaml:"user"`
}
type ReleaseReplaceEntry struct {
Src string `json:"src"`
Dest string `json:"dest"`
Src string `yaml:"src"`
Dest string `yaml:"dest"`
}
type HyprVar struct {
Name string `json:"name"`
Value string `json:"value"`
Name string `yaml:"name"`
Value string `yaml:"value"`
}
type HyprModule struct {
Module string `json:"module"`
User bool `json:"user,omitempty"`
NewOnly bool `json:"new-only,omitempty"`
IfExec string `json:"if-exec,omitempty"`
Module string `yaml:"module"`
User bool `yaml:"user,omitempty"`
NewOnly bool `yaml:"new-only,omitempty"`
IfExec string `yaml:"if-exec,omitempty"`
}
type Profile struct {
Binary string `json:"binary,omitempty"`
Copy []CopyEntry `json:"copy,omitempty"`
Links []LinkEntry `json:"links"`
ReleaseReplace []ReleaseReplaceEntry `json:"release-replace,omitempty"`
Binary string `yaml:"binary,omitempty"`
Copy []CopyEntry `yaml:"copy,omitempty"`
Links []LinkEntry `yaml:"links"`
ReleaseReplace []ReleaseReplaceEntry `yaml:"release-replace,omitempty"`
// ----- hyprland -----
SyncSystemLayouts bool `json:"sync-system-layouts,omitempty"`
HyprVars []HyprVar `json:"hyprvars,omitempty"`
HyprModules []HyprModule `json:"hyprmodules,omitempty"`
SyncSystemLayouts bool `yaml:"sync-system-layouts,omitempty"`
HyprVars []HyprVar `yaml:"hyprvars,omitempty"`
HyprModules []HyprModule `yaml:"hyprmodules,omitempty"`
}
type Config struct {
Profiles map[string]Profile `json:"profiles"`
Profiles map[string]Profile `yaml:"profiles"`
}
type Result struct {
......
......@@ -6,6 +6,7 @@ require (
github.com/fatih/color v1.18.0
github.com/godbus/dbus/v5 v5.1.0
github.com/urfave/cli/v3 v3.4.1
gopkg.in/yaml.v3 v3.0.1
)
require (
......
......@@ -19,5 +19,7 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment