Documentation ¶
Overview ¶
Package darkman implements darkman's service itself.
This package is used by gitlab.com/WhyNotHugo/darkman/cmd, which is the cli that wraps around the service and the client.
Index ¶
- Constants
- func BoolFromYaml(yamlConfig map[interface{}]interface{}, key string) (*bool, error)
- func ExecuteService() error
- func FloatFromYaml(yamlConfig map[interface{}]interface{}, key string) (*float64, error)
- func GetLocations(onLocation func(geoclue.Location)) (err error)
- func NewScheduler(initialLocation *geoclue.Location, changeCallback func(Mode), useGeoclue bool) error
- func NextSunriseAndSundown(loc geoclue.Location, now time.Time) (sunrise time.Time, sundown time.Time, err error)
- func ReadBoolEnvVar(name string) (*bool, error)
- func ReadFloatEnvVar(name string) (*float64, error)
- func RunScripts(mode Mode)
- func SunriseAndSundown(loc geoclue.Location, now time.Time) (sunrise time.Time, sundown time.Time, err error)
- type Config
- type Mode
- type PortalHandle
- type Scheduler
- type ServerHandle
- type Service
Constants ¶
const PORTAL_BUS_NAME = "org.freedesktop.impl.portal.desktop.darkman"
const PORTAL_INTERFACE = "org.freedesktop.impl.portal.Settings"
const PORTAL_KEY = "color-scheme"
const PORTAL_NAMESPACE = "org.freedesktop.appearance"
const PORTAL_OBJ_PATH = "/org/freedesktop/portal/desktop"
Variables ¶
This section is empty.
Functions ¶
func BoolFromYaml ¶ added in v1.5.0
Returns nil if the variable is unset.
func FloatFromYaml ¶ added in v1.5.0
Returns nil if the variable is unset.
func GetLocations ¶
Periodically fetch the current location.
By default, we indicate set geoclue in a rather passive mode; it'll ignore location changes that occurr in less than four hours, or of less than 40km.
func NewScheduler ¶
func NewScheduler(initialLocation *geoclue.Location, changeCallback func(Mode), useGeoclue bool) error
The scheduler schedules timer to wake up in time for the next sundown/sunrise.
func NextSunriseAndSundown ¶
func NextSunriseAndSundown(loc geoclue.Location, now time.Time) (sunrise time.Time, sundown time.Time, err error)
Returns the time of the next sunrise and the next sundown. Note that they next sundown may be before the next sunrise or viceversa.
func ReadBoolEnvVar ¶ added in v1.5.0
Returns nil if the environment variable is unset.
func ReadFloatEnvVar ¶ added in v1.5.0
Returns nil if the environment variable is unset.
func RunScripts ¶
func RunScripts(mode Mode)
Run transition scripts for a given mode.
Fires up all scripts asyncrhonously and returns immediately.
Types ¶
type Config ¶
func ReadConfig ¶
func (*Config) LoadFromEnv ¶ added in v1.5.0
Loads and updates configuration in place.
Returns error for invalid settings. All fields are considered optional.
func (*Config) LoadFromYamlFile ¶ added in v1.5.0
Loads a new configuration.
Returns error for invalid settings. All fields are considered optional.
type Mode ¶
type Mode string
func CalculateCurrentMode ¶
func DetermineModeForRightNow ¶ added in v1.4.0
func GetInitialMode ¶ added in v1.4.0
Gets the initial mode. If the location is known, the mode is computed for that location. Unless the device has travelled across timezones, it should be the correct setting. Otherwise, load the last-known mode. This work well for manually controlled devices, which are unlikely to have a "last known location".
type PortalHandle ¶ added in v1.0.0
type PortalHandle struct {
// contains filtered or unexported fields
}
func NewPortal ¶ added in v1.0.0
func NewPortal(initial Mode) (*PortalHandle, func(Mode), error)
Create a new D-Bus server instance for the XDG portal API.
Returns a callback function which should be called each time the current mode changes.
func (*PortalHandle) Read ¶ added in v1.0.0
func (portal *PortalHandle) Read(namespace string, key string) (dbus.Variant, *dbus.Error)
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler handles setting timers based on the current location, and trigering changes based on the current location and sun position.
func (*Scheduler) Tick ¶
func (handler *Scheduler) Tick()
A single tick.
Update the mode based on the current time, execute transition, and set the timer for the next tick.
func (*Scheduler) UpdateLocation ¶
type ServerHandle ¶
type ServerHandle struct {
// contains filtered or unexported fields
}
func NewDbusServer ¶
func NewDbusServer(initial Mode, onChange func(Mode)) (*ServerHandle, func(Mode), error)
Create a new D-Bus server instance for our API.
Takes as parameter a function that will be called each time the current mode is changed via this D-Bus API.
Returns a callback function which should be called each time the current mode changes by some other mechanism.
func (*ServerHandle) Close ¶
func (handle *ServerHandle) Close() error
type Service ¶ added in v1.0.0
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶ added in v1.4.0
Creates a new Service instance.
func (*Service) AddListener ¶ added in v1.0.0
Add a callback to be run each time the current mode changes.
func (*Service) ChangeMode ¶ added in v1.0.0
Change the current mode (and run all callbacks).
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package boottimer provides a timer that is accurate over suspend.
|
Package boottimer provides a timer that is accurate over suspend. |
cmd
|
|
Package geoclue implements a client for Geoclue's D-Bus.
|
Package geoclue implements a client for Geoclue's D-Bus. |
Package implementing a wrapper around darkman's D-Bus API.
|
Package implementing a wrapper around darkman's D-Bus API. |