initial setup of an app to toggle acpi wakeup devices

This commit is contained in:
2024-05-17 15:52:43 +02:00
parent b7c9a19f6a
commit 3edb64f1ed
6 changed files with 337 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
package procfs
import (
"fmt"
"io"
"os"
)
const (
acpiWakeupDefaultPath = "/proc/acpi/wakeup"
)
type Procfs interface {
ACPIWakeup() (io.ReadCloser, error)
ACPIWakeupWrite() (io.WriteCloser, error)
}
type ProcfsDefaultPath struct{}
func (p *ProcfsDefaultPath) ACPIWakeup() (io.ReadCloser, error) {
f, err := os.Open(acpiWakeupDefaultPath)
if err != nil {
return nil, fmt.Errorf("failed to open %s: %w", acpiWakeupDefaultPath, err)
}
return f, nil
}
func (p *ProcfsDefaultPath) ACPIWakeupWrite() (io.WriteCloser, error) {
f, err := os.OpenFile(acpiWakeupDefaultPath, os.O_WRONLY, 0)
if err != nil {
return nil, fmt.Errorf("failed to open for writing %s: %w", acpiWakeupDefaultPath, err)
}
return f, nil
}