systemd

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsOrbitUnit

func IsOrbitUnit(name string) bool

IsOrbitUnit returns true if the unit name is managed by orbit.

func ReminderServiceName

func ReminderServiceName(name string) string

ReminderServiceName returns the systemd service unit name for a reminder.

func ReminderTimerName

func ReminderTimerName(name string) string

ReminderTimerName returns the systemd timer unit name for a reminder.

func SnoozeTimerName

func SnoozeTimerName(name string) string

SnoozeTimerName returns the systemd timer unit name for a snoozed reminder.

func TaskServiceName

func TaskServiceName(name string) string

TaskServiceName returns the systemd service unit name for a task.

func TaskTimerName

func TaskTimerName(name string) string

TaskTimerName returns the systemd timer unit name for a task.

Types

type ChangeSet

type ChangeSet struct {
	Create []Unit // new units to create
	Update []Unit // existing units whose content changed
	Remove []Unit // units to delete
	Keep   []Unit // units that are already up-to-date
}

ChangeSet describes the set of changes needed to reconcile desired state.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles systemd unit operations (always user-mode).

func NewManager

func NewManager(orbitPath string) *Manager

NewManager creates a new systemd manager for user-level units. orbitPath is the absolute path to the orbit binary, used in generated unit files.

func (*Manager) ApplyUnits

func (m *Manager) ApplyUnits(units []Unit) error

ApplyUnits writes all units to disk, reloads the daemon once, then enables and starts any timer units.

func (*Manager) ClassifyChanges

func (m *Manager) ClassifyChanges(desired []Unit, existingNames []string) ChangeSet

ClassifyChanges compares desired units against what's on disk and returns a ChangeSet. This is the foundation for a future `orbit plan` command.

func (*Manager) EnableAndStartTimer

func (m *Manager) EnableAndStartTimer(timerName string)

EnableAndStartTimer enables and starts a timer unit.

func (*Manager) EnableAndStartTimers

func (m *Manager) EnableAndStartTimers(timerNames []string)

EnableAndStartTimers enables and starts multiple timer units in batch.

func (*Manager) GenerateReminderUnits

func (m *Manager) GenerateReminderUnits(name, schedule string) ([]Unit, error)

GenerateReminderUnits generates service and timer units for a reminder. schedule is a systemd OnCalendar expression.

func (*Manager) GenerateSnoozeTimer

func (m *Manager) GenerateSnoozeTimer(name string, until time.Time) (Unit, error)

GenerateSnoozeTimer generates a persistent snooze timer for a reminder. The timer triggers the reminder's existing service unit at the specified time.

func (*Manager) GenerateTaskUnits

func (m *Manager) GenerateTaskUnits(name, schedule string, onMissed config.OnMissedPolicy) ([]Unit, error)

GenerateTaskUnits generates units for a task. If schedule is empty, only a service unit is generated (no timer). Otherwise, both a service and timer unit are generated.

func (*Manager) ListUnits

func (m *Manager) ListUnits() ([]string, error)

ListUnits returns the names of all orbit-managed units known to systemd.

func (*Manager) RemoveUnits

func (m *Manager) RemoveUnits(units []Unit) error

RemoveUnits stops, disables, and deletes the given units, then reloads the daemon once.

func (*Manager) StopAndDisableTimer

func (m *Manager) StopAndDisableTimer(timerName string)

StopAndDisableTimer stops and disables a timer unit.

func (*Manager) StopAndDisableTimers

func (m *Manager) StopAndDisableTimers(timerNames []string)

StopAndDisableTimers stops and disables multiple timer units in batch.

type Systemctl

type Systemctl interface {
	// Run executes a systemctl command and returns combined output.
	// Returns ("", nil) on success if there's no meaningful output.
	Run(args ...string) (string, error)
}

Systemctl abstracts systemctl command execution for testability.

type Unit

type Unit struct {
	Name       string
	Content    string
	OldContent string // populated for updates only: the previous on-disk content
}

Unit represents a systemd unit file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL