cmd

package
v0.0.0-...-087d875 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 19 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func Execute

func Execute() error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL