Documentation
¶
Overview ¶
Package lock is the login screen in its lock mode: an ext-session-lock surface per output, so the compositor blanks every output, routes input only here, and keeps the session locked if the shell dies. The password is verified by a PAM conversation on a worker goroutine (service/auth), so the event loop is never stalled.
Triggers: logind's Lock and Unlock signals (loginctl lock-session, idle daemons), the dev.stubbe.lys.Shell1 Lock method (`lys-shell lock`, lys-lock), lock-on-start for autologin sessions, and the LockedHint restart recovery. The screen reports its state back with SetLockedHint.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrHeld = errors.New("lock: another lys-login holds the session locked") ErrRefused = errors.New("lock: the session was not locked") )
Errors Run ends with, which `lys-login lock` maps to lockclient's exit codes.
Functions ¶
func Run ¶
Run is `lys-login lock`: it locks the session with the login screen in its lock mode and returns once it unlocks, by password or by logind's Unlock. It writes lockclient.LockedLine to stdout when the compositor confirms the lock. One lys-login per session holds the lock: a second Run returns ErrHeld.
func UnlockVault ¶
Types ¶
type Deps ¶
type Deps struct {
Locker locker
Loop loop
// Now is the clock the grace window and the labels read.
Now func() time.Time
// Wall is the clock the screen shows.
Wall loginscreen.WallClock
// NewTimer makes a stopped Timer for a timer re-armed by every key.
NewTimer func(fn func()) Timer
// Auth starts a conversation; the production one is PAM against
// the configured service for the session user.
Auth func(service string, onEvent func(auth.Event)) authHandle
// SetLockedHint reports the state to logind, best effort; it is called on
// the loop, so it must not wait. nil for nothing.
SetLockedHint func(locked bool)
// Decode decodes the background image file, its pixels in mem
// where it can.
Decode func(mem *memory.Shared, path string) (imagedecode.Decoded, error)
// Outputs are the device pixel sizes of the outputs a lock covers,
// which the background is resampled to before it is blurred.
Outputs func() []image.Point
// Forget drops the renderer's copy of a raster that is no longer
// drawn, before its pixels are freed.
Forget func(render.ImageID)
// OnLocked tells whoever waits that the compositor confirmed a lock; it is
// called on the loop, so it must not wait. nil for nothing.
OnLocked func(struct{})
// OnCapsLock calls fn with Caps Lock's state on registering and on
// each change, on the loop, until the stop it returns; nil for no warning.
OnCapsLock func(fn func(on bool)) (stop func())
// OnEnded runs on the loop when a lock ends: unlocked, refused, or
// ended by the compositor; nil for nothing.
OnEnded func()
Media mediaSource
Battery func(onChange func(batteryLevel, bool)) (stop func())
Fingerprint func(onResult func(fprint.Result)) (stop func())
OnKeyboardLayout func(fn func(app.KeyboardLayout)) (stop func())
NextLayout func(steps int)
LabelLayouts func(names []string) ([]layouts.Layout, error)
SwitchUser func()
}
Deps are the screen's collaborators; New fills the production ones.
type Screen ¶
type Screen struct {
// contains filtered or unexported fields
}
Screen is the lock screen component. Every method runs on the event loop; auth events and signals cross into it through Loop.Invoke.
func New ¶
func New(cfg *config.Config, account string, font render.Font, sheet *widget.Stylesheet, d Deps) *Screen
New builds the screen over its collaborators, asking account, the session user's name as the screen shows it, for the password. The prompt shapes text with font; sheet (the shell's stylesheet) styles the surfaces through the lock.css rules.
func (*Screen) Activity ¶
func (s *Screen) Activity()
Activity unblanks and re-arms the blank timer. Every key comes through here, so it allocates nothing.
func (*Screen) ForceUnlock ¶
func (s *Screen) ForceUnlock()
ForceUnlock is logind's Unlock: tear down without a password - only something that already authorized it (logind, a PAM agent) sends it.
func (*Screen) Lock ¶
Lock acquires the session lock and covers every output (idempotent while locked). Refused, with a log line, when lock is disabled or the compositor lacks ext-session-lock-v1.
func (*Screen) SetPicture ¶
SetPicture shows img as the session user's avatar on every face, and on every face built after.