feat: add reboot and shutdown

This commit is contained in:
2025-05-13 14:37:32 +02:00
parent 9c80c1e771
commit ee0489dcbb
7 changed files with 144 additions and 21 deletions

23
pkg/system/dbus.go Normal file
View File

@@ -0,0 +1,23 @@
package system
import (
"log"
"github.com/godbus/dbus/v5"
)
// WithDbus executes the given function with a D-Bus system connection
// and handles any connection errors
func WithDbus(fn func(*dbus.Conn) error) error {
conn, err := dbus.SystemBus()
if err != nil {
log.Printf("Failed to connect to system bus: %v", err)
return err
}
if err := fn(conn); err != nil {
log.Print(err)
return err
}
conn.Close()
return nil
}