Initial commit: Go driver for the Lian Li Galahad II LCD
Streams H.264 to the Galahad II LCD via USB (gousb) with: - ffmpeg CLI transcoding (no fragile FFmpeg C-ABI bindings) - pure-Go Annex-B access-unit splitting - framerate pacing with graceful shutdown and USB reconnect - TOML config, cobra CLI, structured slog logging, unit tests
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
// Package service manages the galahad2lcd systemd unit.
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
// Service represents the installed systemd unit.
|
||||
type Service struct {
|
||||
name string
|
||||
// runCmd is the command constructor; overridable for tests.
|
||||
runCmd func(ctx context.Context, name string, arg ...string) *exec.Cmd
|
||||
}
|
||||
|
||||
// New returns a Service wrapper for the given unit name.
|
||||
func New(name string) *Service {
|
||||
return &Service{name: name, runCmd: exec.CommandContext}
|
||||
}
|
||||
|
||||
// Restart tells systemd to restart the service. It fails early when the
|
||||
// caller lacks privileges.
|
||||
func (s *Service) Restart(ctx context.Context) error {
|
||||
cmd := s.runCmd(ctx, "systemctl", "restart", s.name)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
if len(out) > 0 {
|
||||
return fmt.Errorf("systemctl restart %s: %w (%s)", s.name, err, string(out))
|
||||
}
|
||||
return fmt.Errorf("systemctl restart %s: %w", s.name, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user