lock

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 50 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func Run(cfg *config.Config, stdout io.Writer, vaultHelper []string) error

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

func UnlockVault(r io.Reader) error

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

func (s *Screen) Lock() error

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) Locked

func (s *Screen) Locked() bool

Locked reports whether a lock is pending or held.

func (*Screen) SetPicture

func (s *Screen) SetPicture(img image.Image)

SetPicture shows img as the session user's avatar on every face, and on every face built after.

func (*Screen) Submit

func (s *Screen) Submit(value string)

Submit handles one Enter in a password entry. The first submit of a lock session starts a PAM conversation and stashes the value for its first prompt; a submit while a later prompt is on screen (an expired password, an OTP) answers it.

type Timer

type Timer interface {
	Reset(d time.Duration)
	Stop()
}

Timer runs the function it was made with on the loop, once per Reset. A firing already on its way when Reset or Stop comes may still arrive, so the function checks it is due.

Jump to

Keyboard shortcuts

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