Skip to content

Commit 974c4f7

Browse files
committed
feat!: change profile specification
1 parent 9f93b4c commit 974c4f7

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

examples/chicago95.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
{
2-
"X-Metadata": {
2+
"metadata": {
33
"version": 1,
44
"name": "winblues-blue95"
55
},
6-
"xsettings": {
7-
"/Net/ThemeName": "Chicago95",
8-
"/Net/IconThemeName": "Chicago95"
9-
},
10-
"xfwm4": {
11-
"/general/theme": "Chicago95"
6+
"properties": {
7+
"xsettings": {
8+
"/Net/ThemeName": "Chicago95",
9+
"/Net/IconThemeName": "Chicago95"
10+
},
11+
"xfwm4": {
12+
"/general/theme": "Chicago95"
13+
}
1214
}
1315
}

src/profile.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ import (
1212
"github.com/fatih/color"
1313
)
1414

15-
type Profile map[string]map[string]any
15+
type Properties map[string]map[string]string
16+
17+
type Profile struct {
18+
Properties Properties `json:"properties"`
19+
}
1620

1721
// TODO: return a new profile that only includes properties that were actually changed based on the merge and exclude settings.
1822
func applyProfile(profilePath string, mergeBehavior MergeBehavior, exclude ExcludePatterns, dryRun bool) error {
@@ -32,7 +36,7 @@ func applyProfile(profilePath string, mergeBehavior MergeBehavior, exclude Exclu
3236

3337
// Get all the default values
3438
defaultValueQueries := make(map[string][]string)
35-
for channel, properties := range profile {
39+
for channel, properties := range profile.Properties {
3640
defaultValueQueries[channel] = []string{}
3741
for property, _ := range properties {
3842
defaultValueQueries[channel] = append(defaultValueQueries[channel], property)
@@ -49,7 +53,7 @@ func applyProfile(profilePath string, mergeBehavior MergeBehavior, exclude Exclu
4953
return fmt.Errorf("could not get current property values: %v", err)
5054
}
5155

52-
for channel, properties := range profile {
56+
for channel, properties := range profile.Properties {
5357
// Keys starting with X- are not channels
5458
if strings.HasPrefix(channel, "X-") {
5559
continue
@@ -115,7 +119,7 @@ func revertProfile(profilePath string, exclude ExcludePatterns, dryRun bool) err
115119
blue := color.New(color.FgHiBlue).SprintFunc()
116120
yellow := color.New(color.FgHiYellow).SprintFunc()
117121

118-
for channel, properties := range profile {
122+
for channel, properties := range profile.Properties {
119123
// Keys starting with X- are not channels
120124
if strings.HasPrefix(channel, "X-") {
121125
continue

0 commit comments

Comments
 (0)