bar/internal/providers/providers.go
AKP e5d4c690e7
Alter 5 files
Update main.go
Update i3bar.go
Add backlight.go
Update cpu.go
Update providers.go
2025-03-05 01:26:53 +00:00

28 lines
571 B
Go

package providers
import (
"bytes"
"fmt"
"os/exec"
"strings"
)
func runCommand(program string, args ...string) ([]byte, error) {
cmd := exec.Command(program, args...)
out, err := cmd.Output()
if err != nil {
ne := fmt.Errorf(`failed to execute "%v" (%+v)`, strings.Join(append([]string{program}, args...), " "), err)
if x, ok := err.(*exec.ExitError); ok {
return bytes.TrimSpace(x.Stderr), ne
}
return nil, ne
}
return bytes.TrimSpace(out), err
}
func leftPad(x string, c rune, n int) string {
for len(x) < n {
x = string(c) + x
}
return x
}