Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ThemeCmd = &cobra.Command{ Use: "theme <theme-name|auto>", Short: "Switch Nucleus Shell color theme", Args: func(cmd *cobra.Command, args []string) error { if listThemes { return nil } if len(args) != 1 { return prompt.Fail("you must specify a theme name or use --list") } return nil }, RunE: func(cmd *cobra.Command, args []string) error { if !config.IsInstalled() { return prompt.Fail("Nucleus Shell is not installed. Run 'nucleus install' first.") } home, err := os.UserHomeDir() if err != nil { return err } themeDir := filepath.Join(home, ".config/nucleus-shell/colorschemes") target := filepath.Join(home, ".config/nucleus-shell/config/colors.json") if listThemes { entries, err := os.ReadDir(themeDir) if err != nil { return err } var themes []string for _, e := range entries { if e.IsDir() { continue } if strings.HasSuffix(e.Name(), ".json") { themes = append(themes, strings.TrimSuffix(e.Name(), ".json")) } } sort.Strings(themes) for _, t := range themes { fmt.Println(t) } return nil } themeName := args[0] if themeName == "auto" || themeName == "autogen" { prompt.Stage("Generating theme via Quickshell IPC…") ipc.RunShellIPCCommand([]string{ "global", "regenColors", }) prompt.Success("Autogenerated theme applied") return nil } source := filepath.Join(themeDir, themeName+".json") if _, err := os.Stat(source); err != nil { if os.IsNotExist(err) { return prompt.Fail("theme not found: " + themeName) } return err } tmp, err := os.CreateTemp("", "colors-*.json") if err != nil { return err } defer os.Remove(tmp.Name()) data, err := os.ReadFile(source) if err != nil { return err } if _, err := tmp.Write(data); err != nil { return err } if err := tmp.Close(); err != nil { return err } if err := os.Rename(tmp.Name(), target); err != nil { return err } prompt.Success("Theme switched to:", themeName) return nil }, }
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.