Files
devplacepy/nodes/client/battery_darwin.go
T

20 lines
350 B
Go
Raw Normal View History

//go:build darwin
package main
import (
"context"
"os/exec"
"time"
)
func systemBattery() (bool, error) {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
out, err := exec.CommandContext(ctx, "pmset", "-g", "batt").Output()
if err != nil {
return false, err
}
return parsePmset(string(out)), nil
}