ScreenLocked · SetScreenLocked
This tool on every surface: CLI · MCP · Python · JavaScript · Go · Java · .NET
Read whether the screen is locked, or lock and unlock it. These call app_lock.
ScreenLocked
func (d *Device) ScreenLocked(ctx context.Context) (bool, error)
ScreenLocked reports whether the screen is locked.
SetScreenLocked
func (d *Device) SetScreenLocked(ctx context.Context, locked bool) error
SetScreenLocked locks or unlocks the screen and confirms it.
A state rather than a power-button press: power is a toggle, so asking twice leaves the device where it started. A device with a PIN, pattern or password cannot be unlocked from outside and returns an error rather than pretending.
Examples
Lock the screen
if err := dev.SetScreenLocked(ctx, true); err != nil {
return err
}
Unlock it
if err := dev.SetScreenLocked(ctx, false); err != nil {
return err
}