MCPcopy
hub / github.com/spicetify/cli / refreshThemeCSS

Function refreshThemeCSS

src/cmd/apply.go:122–165  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

120}
121
122func refreshThemeCSS() {
123 spinner, _ := utils.Spinner.Start("Updating theme's styles")
124 var scheme map[string]string = nil
125 if colorSection != nil {
126 scheme = colorSection.KeysHash()
127 }
128 theme := themeFolder
129 if !injectCSS {
130 theme = ""
131 }
132 apply.UserCSS(appDestPath, theme, scheme)
133
134 var configJson spicetifyConfigJson
135 configJson.ThemeName = settingSection.Key("current_theme").MustString("")
136 configJson.SchemeName = settingSection.Key("color_scheme").MustString("")
137
138 if colorCfg != nil {
139 colorsJson := make(map[string]map[string]string)
140 for _, section := range colorCfg.Sections() {
141 name := section.Name()
142 colorsJson[name] = make(map[string]string)
143
144 for _, key := range section.Keys() {
145 colorsJson[name][key.Name()] = key.MustString("")
146 }
147 }
148 configJson.Schemes = colorsJson
149 }
150
151 configJsonBytes, err := json.MarshalIndent(configJson, "", " ")
152 if err != nil {
153 spinner.Fail("Failed to update theme's styles")
154 utils.PrintError("Cannot convert colors.ini to JSON")
155 } else {
156 if err := os.WriteFile(
157 filepath.Join(appDestPath, "xpui", "spicetify-config.json"),
158 configJsonBytes, 0700); err != nil {
159 spinner.Fail("Failed to update theme's styles")
160 utils.PrintError(err.Error())
161 } else {
162 spinner.Success("Updated theme's styles")
163 }
164 }
165}
166
167func refreshThemeAssets() {
168 spinner, _ := utils.Spinner.Start("Updating custom assets")

Callers 2

RefreshThemeFunction · 0.85
WatchFunction · 0.85

Calls 2

UserCSSFunction · 0.92
PrintErrorFunction · 0.92

Tested by

no test coverage detected