Exemplo n.º 1
0
func (b *Battery) ChargeFull() int64 {
	var str string
	if helper.IsFile(psp(b.Key, "energy_full")) {
		str, _ = helper.StringFromFile(psp(b.Key, "energy_full"))
	} else {
		str, _ = helper.StringFromFile(psp(b.Key, "charge_full"))
	}
	i, _ := strconv.ParseInt(str, 10, 64)
	return i
}
Exemplo n.º 2
0
func (g *GenericPowerSupply) GetInfo() (*Info, error) {
	info := Info{
		Key:     g.Key,
		Time:    time.Now().UnixNano(),
		Values:  map[string]string{},
		Load:    GetLoadAvg(),
		Version: GetVersion(),
	}
	files, err := filepath.Glob(filepath.Join(PowerSupplyPath, g.Key, "*"))
	if err != nil {
		return nil, err
	}
	for _, file := range files {
		if helper.IsFile(file) {
			if str, err := helper.StringFromFile(file); err == nil {
				info.Values[filepath.Base(file)] = str
			}
		}
	}

	return &info, nil
}