Documentation
¶
Index ¶
- Variables
- func AskForLocales(defaultLocales ...[]string) []string
- func EnsureStringAndValid(name string, value interface{}, err error) (string, error)
- func GetDataFromMetadata(key string) (interface{}, error)
- func GetDevDest() (string, error)
- func InstallDependencies() error
- func IsInstalled() (bool, string, error)
- func IsLinked() bool
- func IsQmlFile(filename string) bool
- func IsValidPlasmoid() bool
- func LoadConfigRC() types.Config
- func UpdateMetadata(key string, value interface{}, sectionOpt ...string) error
Constants ¶
This section is empty.
Variables ¶
View Source
var DetectPackageManager = func() (string, error) { for binary, pm := range supportedPackageManagers { _, err := execLookPath(binary) if err == nil { return pm, nil } } return "", fmt.Errorf("no supported package manager found: %+v", supportedPackageManagers) }
Detect package manager
View Source
var GetBinPath = func() (string, error) { defaultCandidates := []string{ "/usr/bin", "/usr/local/bin", "/bin", "/nix/var/nix/profiles/default/bin", } pathEnv := os.Getenv("PATH") paths := strings.Split(pathEnv, ":") for _, candidate := range defaultCandidates { for _, p := range paths { if p == candidate { if info, err := os.Stat(p); err == nil && info.IsDir() { return p, nil } } } } return "", fmt.Errorf("no supported bin path found: %+v", defaultCandidates) }
View Source
var InstallPackage = func(pm, binName string, pkgNames map[string]string) error { binPath, err := getBinPath() if err != nil { return fmt.Errorf("failed to get bin path: %v", err) } pkgName, ok := pkgNames[pm] if !ok { return fmt.Errorf("unsupported package manager: %s", pm) } var cmd *exec.Cmd switch pm { case "nix": cmd = execCommand("nix-env", "-iA", pkgName) case "pacman": cmd = execCommand("sudo", "pacman", "-S", "--noconfirm", pkgName) default: cmd = execCommand("sudo", pm, "install", "-y", pkgName) } cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { color.Yellow("Warning: install command exited with error: %v", err) } if err := ensureBinaryLinked(binName, binPath); err != nil { return err } color.Green("%s installed!", binName) return nil }
View Source
var IsPackageInstalled = func(name string) bool { _, err := execLookPath(name) return err == nil }
Check if package is installed
Functions ¶
func AskForLocales ¶ added in v0.0.3
func EnsureStringAndValid ¶ added in v0.0.3
func GetDataFromMetadata ¶
GetDataFromMetadata reads metadata.json and returns the requested key's value from the KPlugin section
func InstallDependencies ¶ added in v0.0.4
func InstallDependencies() error
func IsValidPlasmoid ¶
func IsValidPlasmoid() bool
func LoadConfigRC ¶
func UpdateMetadata ¶
UpdateMetadata updates a key in the metadata.json file.
Parameters:
- key: The key inside the section to update or create.
- value: The new value to assign to the key.
- section: The top-level section in metadata.json where the key is located. By default, this is "KPlugin", which is the standard location for Plasmoid metadata. If you're updating a key at the root level of the JSON, pass "." as the section.
Behavior:
- If the section does not exist, it will be created automatically.
- If the file cannot be read or parsed, a descriptive error will be returned.
- The resulting JSON will be indented for readability.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.