func (c *Conn) ReloadContext(ctx context.Context) error {
	return c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.Reload", 0).Store()
}
ReloadContext instructs systemd to scan for and reload unit files. This is
an equivalent to systemctl daemon-reload.
package dbus
import (
	"context"
	"errors"
	"fmt"
	"path"
	"strconv"
	"github.com/godbus/dbus/v5"
)
type Who string
const (
	All Who = "all"
	Main Who = "main"
	Control Who = "control"
)
func (c *Conn) jobComplete(signal *dbus.Signal) {
	var id uint32
	var job dbus.ObjectPath
	var unit string
	var result string
	dbus.Store(signal.Body, &id, &job, &unit, &result)
	c.jobListener.Lock()
	out, ok := c.jobListener.jobs[job]
	if ok {
		out <- result
		delete(c.jobListener.jobs, job)
	}
	c.jobListener.Unlock()
}
func (c *Conn) startJob(ctx context.Context, ch chan<- string, job string, args ...interface{}) (int, error) {
	if ch != nil {
		c.jobListener.Lock()
		defer c.jobListener.Unlock()
	}
	var p dbus.ObjectPath
	err := c.sysobj.CallWithContext(ctx, job, 0, args...).Store(&p)
	if err != nil {
		return 0, err
	}
	if ch != nil {
		c.jobListener.jobs[p] = ch
	}
	jobID, _ := strconv.Atoi(path.Base(string(p)))
	return jobID, nil
}
func (c *Conn) StartUnit(name string, mode string, ch chan<- string) (int, error) {
	return c.StartUnitContext(context.Background(), name, mode, ch)
}
func (c *Conn) StartUnitContext(ctx context.Context, name string, mode string, ch chan<- string) (int, error) {
	return c.startJob(ctx, ch, "org.freedesktop.systemd1.Manager.StartUnit", name, mode)
}
func (c *Conn) StopUnit(name string, mode string, ch chan<- string) (int, error) {
	return c.StopUnitContext(context.Background(), name, mode, ch)
}
func (c *Conn) StopUnitContext(ctx context.Context, name string, mode string, ch chan<- string) (int, error) {
	return c.startJob(ctx, ch, "org.freedesktop.systemd1.Manager.StopUnit", name, mode)
}
func (c *Conn) ReloadUnit(name string, mode string, ch chan<- string) (int, error) {
	return c.ReloadUnitContext(context.Background(), name, mode, ch)
}
func (c *Conn) ReloadUnitContext(ctx context.Context, name string, mode string, ch chan<- string) (int, error) {
	return c.startJob(ctx, ch, "org.freedesktop.systemd1.Manager.ReloadUnit", name, mode)
}
func (c *Conn) RestartUnit(name string, mode string, ch chan<- string) (int, error) {
	return c.RestartUnitContext(context.Background(), name, mode, ch)
}
func (c *Conn) RestartUnitContext(ctx context.Context, name string, mode string, ch chan<- string) (int, error) {
	return c.startJob(ctx, ch, "org.freedesktop.systemd1.Manager.RestartUnit", name, mode)
}
func (c *Conn) TryRestartUnit(name string, mode string, ch chan<- string) (int, error) {
	return c.TryRestartUnitContext(context.Background(), name, mode, ch)
}
func (c *Conn) TryRestartUnitContext(ctx context.Context, name string, mode string, ch chan<- string) (int, error) {
	return c.startJob(ctx, ch, "org.freedesktop.systemd1.Manager.TryRestartUnit", name, mode)
}
func (c *Conn) ReloadOrRestartUnit(name string, mode string, ch chan<- string) (int, error) {
	return c.ReloadOrRestartUnitContext(context.Background(), name, mode, ch)
}
func (c *Conn) ReloadOrRestartUnitContext(ctx context.Context, name string, mode string, ch chan<- string) (int, error) {
	return c.startJob(ctx, ch, "org.freedesktop.systemd1.Manager.ReloadOrRestartUnit", name, mode)
}
func (c *Conn) ReloadOrTryRestartUnit(name string, mode string, ch chan<- string) (int, error) {
	return c.ReloadOrTryRestartUnitContext(context.Background(), name, mode, ch)
}
func (c *Conn) ReloadOrTryRestartUnitContext(ctx context.Context, name string, mode string, ch chan<- string) (int, error) {
	return c.startJob(ctx, ch, "org.freedesktop.systemd1.Manager.ReloadOrTryRestartUnit", name, mode)
}
func (c *Conn) StartTransientUnit(name string, mode string, properties []Property, ch chan<- string) (int, error) {
	return c.StartTransientUnitContext(context.Background(), name, mode, properties, ch)
}
func (c *Conn) StartTransientUnitContext(ctx context.Context, name string, mode string, properties []Property, ch chan<- string) (int, error) {
	return c.startJob(ctx, ch, "org.freedesktop.systemd1.Manager.StartTransientUnit", name, mode, properties, make([]PropertyCollection, 0))
}
func (c *Conn) KillUnit(name string, signal int32) {
	c.KillUnitContext(context.Background(), name, signal)
}
func (c *Conn) KillUnitContext(ctx context.Context, name string, signal int32) {
	c.KillUnitWithTarget(ctx, name, All, signal)
}
func (c *Conn) KillUnitWithTarget(ctx context.Context, name string, target Who, signal int32) error {
	return c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.KillUnit", 0, name, string(target), signal).Store()
}
func (c *Conn) ResetFailedUnit(name string) error {
	return c.ResetFailedUnitContext(context.Background(), name)
}
func (c *Conn) ResetFailedUnitContext(ctx context.Context, name string) error {
	return c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ResetFailedUnit", 0, name).Store()
}
func (c *Conn) SystemState() (*Property, error) {
	return c.SystemStateContext(context.Background())
}
func (c *Conn) SystemStateContext(ctx context.Context) (*Property, error) {
	var err error
	var prop dbus.Variant
	obj := c.sysconn.Object("org.freedesktop.systemd1", "/org/freedesktop/systemd1")
	err = obj.CallWithContext(ctx, "org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.systemd1.Manager", "SystemState").Store(&prop)
	if err != nil {
		return nil, err
	}
	return &Property{Name: "SystemState", Value: prop}, nil
}
func (c *Conn) getProperties(ctx context.Context, path dbus.ObjectPath, dbusInterface string) (map[string]interface{}, error) {
	var err error
	var props map[string]dbus.Variant
	if !path.IsValid() {
		return nil, fmt.Errorf("invalid unit name: %v", path)
	}
	obj := c.sysconn.Object("org.freedesktop.systemd1", path)
	err = obj.CallWithContext(ctx, "org.freedesktop.DBus.Properties.GetAll", 0, dbusInterface).Store(&props)
	if err != nil {
		return nil, err
	}
	out := make(map[string]interface{}, len(props))
	for k, v := range props {
		out[k] = v.Value()
	}
	return out, nil
}
func (c *Conn) GetUnitProperties(unit string) (map[string]interface{}, error) {
	return c.GetUnitPropertiesContext(context.Background(), unit)
}
func (c *Conn) GetUnitPropertiesContext(ctx context.Context, unit string) (map[string]interface{}, error) {
	path := unitPath(unit)
	return c.getProperties(ctx, path, "org.freedesktop.systemd1.Unit")
}
func (c *Conn) GetUnitPathProperties(path dbus.ObjectPath) (map[string]interface{}, error) {
	return c.GetUnitPathPropertiesContext(context.Background(), path)
}
func (c *Conn) GetUnitPathPropertiesContext(ctx context.Context, path dbus.ObjectPath) (map[string]interface{}, error) {
	return c.getProperties(ctx, path, "org.freedesktop.systemd1.Unit")
}
func (c *Conn) GetAllProperties(unit string) (map[string]interface{}, error) {
	return c.GetAllPropertiesContext(context.Background(), unit)
}
func (c *Conn) GetAllPropertiesContext(ctx context.Context, unit string) (map[string]interface{}, error) {
	path := unitPath(unit)
	return c.getProperties(ctx, path, "")
}
func (c *Conn) getProperty(ctx context.Context, unit string, dbusInterface string, propertyName string) (*Property, error) {
	var err error
	var prop dbus.Variant
	path := unitPath(unit)
	if !path.IsValid() {
		return nil, errors.New("invalid unit name: " + unit)
	}
	obj := c.sysconn.Object("org.freedesktop.systemd1", path)
	err = obj.CallWithContext(ctx, "org.freedesktop.DBus.Properties.Get", 0, dbusInterface, propertyName).Store(&prop)
	if err != nil {
		return nil, err
	}
	return &Property{Name: propertyName, Value: prop}, nil
}
func (c *Conn) GetUnitProperty(unit string, propertyName string) (*Property, error) {
	return c.GetUnitPropertyContext(context.Background(), unit, propertyName)
}
func (c *Conn) GetUnitPropertyContext(ctx context.Context, unit string, propertyName string) (*Property, error) {
	return c.getProperty(ctx, unit, "org.freedesktop.systemd1.Unit", propertyName)
}
func (c *Conn) GetServiceProperty(service string, propertyName string) (*Property, error) {
	return c.GetServicePropertyContext(context.Background(), service, propertyName)
}
func (c *Conn) GetServicePropertyContext(ctx context.Context, service string, propertyName string) (*Property, error) {
	return c.getProperty(ctx, service, "org.freedesktop.systemd1.Service", propertyName)
}
func (c *Conn) GetUnitTypeProperties(unit string, unitType string) (map[string]interface{}, error) {
	return c.GetUnitTypePropertiesContext(context.Background(), unit, unitType)
}
func (c *Conn) GetUnitTypePropertiesContext(ctx context.Context, unit string, unitType string) (map[string]interface{}, error) {
	path := unitPath(unit)
	return c.getProperties(ctx, path, "org.freedesktop.systemd1."+unitType)
}
func (c *Conn) SetUnitProperties(name string, runtime bool, properties ...Property) error {
	return c.SetUnitPropertiesContext(context.Background(), name, runtime, properties...)
}
func (c *Conn) SetUnitPropertiesContext(ctx context.Context, name string, runtime bool, properties ...Property) error {
	return c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.SetUnitProperties", 0, name, runtime, properties).Store()
}
func (c *Conn) GetUnitTypeProperty(unit string, unitType string, propertyName string) (*Property, error) {
	return c.GetUnitTypePropertyContext(context.Background(), unit, unitType, propertyName)
}
func (c *Conn) GetUnitTypePropertyContext(ctx context.Context, unit string, unitType string, propertyName string) (*Property, error) {
	return c.getProperty(ctx, unit, "org.freedesktop.systemd1."+unitType, propertyName)
}
type UnitStatus struct {
	Name        string           
	Description string           
	LoadState   string           
	ActiveState string           
	SubState    string           
	Followed    string           
	Path        dbus.ObjectPath  
	JobId       uint32           
	JobType     string           
	JobPath     dbus.ObjectPath  
}
type storeFunc func(retvalues ...interface{}) error
func (c *Conn) listUnitsInternal(f storeFunc) ([]UnitStatus, error) {
	result := make([][]interface{}, 0)
	err := f(&result)
	if err != nil {
		return nil, err
	}
	resultInterface := make([]interface{}, len(result))
	for i := range result {
		resultInterface[i] = result[i]
	}
	status := make([]UnitStatus, len(result))
	statusInterface := make([]interface{}, len(status))
	for i := range status {
		statusInterface[i] = &status[i]
	}
	err = dbus.Store(resultInterface, statusInterface...)
	if err != nil {
		return nil, err
	}
	return status, nil
}
func (c *Conn) ListUnits() ([]UnitStatus, error) {
	return c.ListUnitsContext(context.Background())
}
func (c *Conn) ListUnitsContext(ctx context.Context) ([]UnitStatus, error) {
	return c.listUnitsInternal(c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListUnits", 0).Store)
}
func (c *Conn) ListUnitsFiltered(states []string) ([]UnitStatus, error) {
	return c.ListUnitsFilteredContext(context.Background(), states)
}
func (c *Conn) ListUnitsFilteredContext(ctx context.Context, states []string) ([]UnitStatus, error) {
	return c.listUnitsInternal(c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListUnitsFiltered", 0, states).Store)
}
func (c *Conn) ListUnitsByPatterns(states []string, patterns []string) ([]UnitStatus, error) {
	return c.ListUnitsByPatternsContext(context.Background(), states, patterns)
}
func (c *Conn) ListUnitsByPatternsContext(ctx context.Context, states []string, patterns []string) ([]UnitStatus, error) {
	return c.listUnitsInternal(c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListUnitsByPatterns", 0, states, patterns).Store)
}
func (c *Conn) ListUnitsByNames(units []string) ([]UnitStatus, error) {
	return c.ListUnitsByNamesContext(context.Background(), units)
}
func (c *Conn) ListUnitsByNamesContext(ctx context.Context, units []string) ([]UnitStatus, error) {
	return c.listUnitsInternal(c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListUnitsByNames", 0, units).Store)
}
type UnitFile struct {
	Path string
	Type string
}
func (c *Conn) listUnitFilesInternal(f storeFunc) ([]UnitFile, error) {
	result := make([][]interface{}, 0)
	err := f(&result)
	if err != nil {
		return nil, err
	}
	resultInterface := make([]interface{}, len(result))
	for i := range result {
		resultInterface[i] = result[i]
	}
	files := make([]UnitFile, len(result))
	fileInterface := make([]interface{}, len(files))
	for i := range files {
		fileInterface[i] = &files[i]
	}
	err = dbus.Store(resultInterface, fileInterface...)
	if err != nil {
		return nil, err
	}
	return files, nil
}
func (c *Conn) ListUnitFiles() ([]UnitFile, error) {
	return c.ListUnitFilesContext(context.Background())
}
func (c *Conn) ListUnitFilesContext(ctx context.Context) ([]UnitFile, error) {
	return c.listUnitFilesInternal(c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListUnitFiles", 0).Store)
}
func (c *Conn) ListUnitFilesByPatterns(states []string, patterns []string) ([]UnitFile, error) {
	return c.ListUnitFilesByPatternsContext(context.Background(), states, patterns)
}
func (c *Conn) ListUnitFilesByPatternsContext(ctx context.Context, states []string, patterns []string) ([]UnitFile, error) {
	return c.listUnitFilesInternal(c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListUnitFilesByPatterns", 0, states, patterns).Store)
}
type LinkUnitFileChange EnableUnitFileChange
func (c *Conn) LinkUnitFiles(files []string, runtime bool, force bool) ([]LinkUnitFileChange, error) {
	return c.LinkUnitFilesContext(context.Background(), files, runtime, force)
}
func (c *Conn) LinkUnitFilesContext(ctx context.Context, files []string, runtime bool, force bool) ([]LinkUnitFileChange, error) {
	result := make([][]interface{}, 0)
	err := c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.LinkUnitFiles", 0, files, runtime, force).Store(&result)
	if err != nil {
		return nil, err
	}
	resultInterface := make([]interface{}, len(result))
	for i := range result {
		resultInterface[i] = result[i]
	}
	changes := make([]LinkUnitFileChange, len(result))
	changesInterface := make([]interface{}, len(changes))
	for i := range changes {
		changesInterface[i] = &changes[i]
	}
	err = dbus.Store(resultInterface, changesInterface...)
	if err != nil {
		return nil, err
	}
	return changes, nil
}
func (c *Conn) EnableUnitFiles(files []string, runtime bool, force bool) (bool, []EnableUnitFileChange, error) {
	return c.EnableUnitFilesContext(context.Background(), files, runtime, force)
}
func (c *Conn) EnableUnitFilesContext(ctx context.Context, files []string, runtime bool, force bool) (bool, []EnableUnitFileChange, error) {
	var carries_install_info bool
	result := make([][]interface{}, 0)
	err := c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.EnableUnitFiles", 0, files, runtime, force).Store(&carries_install_info, &result)
	if err != nil {
		return false, nil, err
	}
	resultInterface := make([]interface{}, len(result))
	for i := range result {
		resultInterface[i] = result[i]
	}
	changes := make([]EnableUnitFileChange, len(result))
	changesInterface := make([]interface{}, len(changes))
	for i := range changes {
		changesInterface[i] = &changes[i]
	}
	err = dbus.Store(resultInterface, changesInterface...)
	if err != nil {
		return false, nil, err
	}
	return carries_install_info, changes, nil
}
type EnableUnitFileChange struct {
	Type        string  
	Filename    string  
	Destination string  
}
func (c *Conn) DisableUnitFiles(files []string, runtime bool) ([]DisableUnitFileChange, error) {
	return c.DisableUnitFilesContext(context.Background(), files, runtime)
}
func (c *Conn) DisableUnitFilesContext(ctx context.Context, files []string, runtime bool) ([]DisableUnitFileChange, error) {
	result := make([][]interface{}, 0)
	err := c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.DisableUnitFiles", 0, files, runtime).Store(&result)
	if err != nil {
		return nil, err
	}
	resultInterface := make([]interface{}, len(result))
	for i := range result {
		resultInterface[i] = result[i]
	}
	changes := make([]DisableUnitFileChange, len(result))
	changesInterface := make([]interface{}, len(changes))
	for i := range changes {
		changesInterface[i] = &changes[i]
	}
	err = dbus.Store(resultInterface, changesInterface...)
	if err != nil {
		return nil, err
	}
	return changes, nil
}
type DisableUnitFileChange struct {
	Type        string  
	Filename    string  
	Destination string  
}
func (c *Conn) MaskUnitFiles(files []string, runtime bool, force bool) ([]MaskUnitFileChange, error) {
	return c.MaskUnitFilesContext(context.Background(), files, runtime, force)
}
func (c *Conn) MaskUnitFilesContext(ctx context.Context, files []string, runtime bool, force bool) ([]MaskUnitFileChange, error) {
	result := make([][]interface{}, 0)
	err := c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.MaskUnitFiles", 0, files, runtime, force).Store(&result)
	if err != nil {
		return nil, err
	}
	resultInterface := make([]interface{}, len(result))
	for i := range result {
		resultInterface[i] = result[i]
	}
	changes := make([]MaskUnitFileChange, len(result))
	changesInterface := make([]interface{}, len(changes))
	for i := range changes {
		changesInterface[i] = &changes[i]
	}
	err = dbus.Store(resultInterface, changesInterface...)
	if err != nil {
		return nil, err
	}
	return changes, nil
}
type MaskUnitFileChange struct {
	Type        string  
	Filename    string  
	Destination string  
}
func (c *Conn) UnmaskUnitFiles(files []string, runtime bool) ([]UnmaskUnitFileChange, error) {
	return c.UnmaskUnitFilesContext(context.Background(), files, runtime)
}
func (c *Conn) UnmaskUnitFilesContext(ctx context.Context, files []string, runtime bool) ([]UnmaskUnitFileChange, error) {
	result := make([][]interface{}, 0)
	err := c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.UnmaskUnitFiles", 0, files, runtime).Store(&result)
	if err != nil {
		return nil, err
	}
	resultInterface := make([]interface{}, len(result))
	for i := range result {
		resultInterface[i] = result[i]
	}
	changes := make([]UnmaskUnitFileChange, len(result))
	changesInterface := make([]interface{}, len(changes))
	for i := range changes {
		changesInterface[i] = &changes[i]
	}
	err = dbus.Store(resultInterface, changesInterface...)
	if err != nil {
		return nil, err
	}
	return changes, nil
}
type UnmaskUnitFileChange struct {
	Type        string  
	Filename    string  
	Destination string  
}
func (c *Conn) Reload() error {
	return c.ReloadContext(context.Background())
}