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 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 CheckRoot = func() error { currentUser, err := userCurrent() if err != nil { return fmt.Errorf("failed to get current user: %v", err) } if currentUser.Uid != "0" { return fmt.Errorf("the requested operation requires superuser privileges. use `sudo %s`", strings.Join(os.Args[0:], " ")) } return nil }
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 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 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.