Lock: add session lock from power button and chandra-ctl lock
CI / test (push) Waiting to run

- Lock the session from the power button or `chandra-ctl lock`
- Unlock with a face or the password; the password always works
- Add compositor lock module with tests, and a polkit unlock policy (org.chandra.unlock)
- Document the lock flow in docs/lock.md and link it from the README
- Add generated interface bindings for the compositor and widget components
This commit is contained in:
nandi committed 2026-11-29 03:24:46 -08:00
1 parent 7501fc3ad9
commit c790f96e58
131 files changed
+4693 -274

No files matched your search

@@ -0,0 +1,32 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/default-apps"
// Values
pub fn apps() -> Array[AppChoice]
pub fn categories() -> Array[AppCategory]
pub fn refresh() -> Unit
pub fn set_default(UInt32, UInt32) -> Unit
// Errors
// Types and methods
pub(all) struct AppCategory {
name : String
current : String
missing : String
}
pub(all) struct AppChoice {
category : UInt32
id : String
name : String
icon : UInt32
current : Bool
}
// Type aliases
// Traits
@@ -0,0 +1,53 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/game-library"
// Values
pub fn focus(String) -> Unit
pub fn games() -> Array[Game]
pub fn launch(String, String) -> Unit
pub fn launch_modes() -> Array[LaunchMode]
pub fn refresh() -> Unit
pub fn status() -> RigStatus
pub fn stop(String) -> Unit
// Errors
// Types and methods
pub(all) struct Game {
id : String
name : String
category : String
description : String
icon : String
install_hint : String
featured : Bool
installed : Bool
running : Bool
}
pub(all) struct LaunchMode {
game : String
id : String
label : String
}
pub(all) struct RigStatus {
error : String
gpu : String
resolution : String
display : String
audio : String
hostname : String
connected : Bool
audio_ok : Bool
}
// Type aliases
// Traits
@@ -0,0 +1,13 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/icons"
// Values
pub fn app_icon(String) -> UInt32
// Errors
// Types and methods
// Type aliases
// Traits
@@ -0,0 +1,15 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/inspector"
// Values
pub fn is_on() -> Bool
pub fn set_on(Bool) -> Unit
// Errors
// Types and methods
// Type aliases
// Traits
@@ -0,0 +1,17 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/layout-control"
// Values
pub fn current_layout() -> UInt32
pub fn layout_modes() -> Array[String]
pub fn set_layout(UInt32) -> Unit
// Errors
// Types and methods
// Type aliases
// Traits
@@ -0,0 +1,35 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/modules"
// Values
pub fn available() -> Array[ModuleInfo]
pub fn browse() -> Unit
pub fn load_module(String) -> Unit
pub fn loaded() -> Array[InstanceInfo]
pub fn move_instance(String, Int32) -> Unit
pub fn unload_instance(String) -> Unit
// Errors
// Types and methods
pub(all) struct InstanceInfo {
slot : String
module_ : String
name : String
}
pub(all) struct ModuleInfo {
id : String
name : String
path : String
loaded : UInt32
}
// Type aliases
// Traits
@@ -0,0 +1,45 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/network"
// Values
pub fn connect(String, String) -> Unit
pub fn disconnect() -> Unit
pub fn forget(String) -> Unit
pub fn scan() -> Unit
pub fn set_airplane_mode(Bool) -> Unit
pub fn set_wifi_enabled(Bool) -> Unit
pub fn status() -> NetStatus
pub fn wifi_networks() -> Array[WifiNetwork]
// Errors
// Types and methods
pub(all) struct NetStatus {
state : UInt32
signal : UInt32
name : String
message : String
wifi_enabled : Bool
airplane : Bool
can_manage : Bool
has_wifi : Bool
}
pub(all) struct WifiNetwork {
ssid : String
signal : UInt32
secured : Bool
active : Bool
saved : Bool
}
// Type aliases
// Traits
+3
View File
@@ -0,0 +1,3 @@
Built-in on-screen keyboard (OSK). The compositor draws the keyboard above the panel and routes
keystrokes to focused Wayland clients, panel popups and dialogs; a module with this capability
reads whether the keyboard is showing and opens or hides it.
+8
View File
@@ -0,0 +1,8 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
///|
fn wasmImportIsVisible() -> Int = "chandra:desktop/osk@0.1.0" "is-visible"
///|
fn wasmImportSetVisible(p0 : Int) = "chandra:desktop/osk@0.1.0" "set-visible"
+1
View File
@@ -0,0 +1 @@
warnings = "-44"
@@ -0,0 +1,15 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/osk"
// Values
pub fn is_visible() -> Bool
pub fn set_visible(Bool) -> Unit
// Errors
// Types and methods
// Type aliases
// Traits
+18
View File
@@ -0,0 +1,18 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
///|
/// Whether the on-screen keyboard is currently visible.
pub fn is_visible() -> Bool {
let result : Int = wasmImportIsVisible();
let ret = (result != 0)
return ret
}
///|
/// Show (true) or hide (false) the on-screen keyboard.
pub fn set_visible(visible : Bool) -> Unit {
wasmImportSetVisible((if visible { 1 } else { 0 }));
}
@@ -0,0 +1,29 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/power"
// Values
pub fn brightness() -> Int32
pub fn power_off() -> Unit
pub fn reboot() -> Unit
pub fn screen_off_minutes() -> UInt32
pub fn set_brightness(UInt32) -> Unit
pub fn set_screen_off_minutes(UInt32) -> Unit
pub fn set_suspend_minutes(UInt32) -> Unit
pub fn suspend() -> Unit
pub fn suspend_minutes() -> UInt32
// Errors
// Types and methods
// Type aliases
// Traits
@@ -0,0 +1,2 @@
Display orientation (0°, 90° CW, 180°, 270° CW). The host rotates scanout and input
coordinates; a module with this capability reads the current orientation and rotates it.
@@ -0,0 +1,8 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
///|
fn wasmImportCurrent() -> Int = "chandra:desktop/rotation@0.1.0" "current"
///|
fn wasmImportSetRotation(p0 : Int) = "chandra:desktop/rotation@0.1.0" "set-rotation"
@@ -0,0 +1 @@
warnings = "-44"
@@ -0,0 +1,15 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/rotation"
// Values
pub fn current() -> UInt32
pub fn set_rotation(UInt32) -> Unit
// Errors
// Types and methods
// Type aliases
// Traits
@@ -0,0 +1,18 @@
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
///|
/// Current orientation: 0 = 0°, 1 = 90° CW, 2 = 180°, 3 = 270° CW.
pub fn current() -> UInt {
let result : Int = wasmImportCurrent();
let ret = (result).reinterpret_as_uint()
return ret
}
///|
/// Set the orientation (0..3, wrapped modulo 4).
pub fn set_rotation(rot : UInt) -> Unit {
wasmImportSetRotation((rot).reinterpret_as_int());
}
@@ -0,0 +1,23 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/screenshot"
// Values
pub fn is_recording() -> Bool
pub fn records_pointer() -> Bool
pub fn set_records_pointer(Bool) -> Unit
pub fn start_recording(UInt32) -> Unit
pub fn stop_recording() -> Unit
pub fn take(UInt32) -> Unit
// Errors
// Types and methods
// Type aliases
// Traits
@@ -0,0 +1,17 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/session-settings"
// Values
pub fn is_on(UInt32) -> Bool
pub fn set_setting(UInt32, Bool) -> Unit
pub fn settings() -> Array[String]
// Errors
// Types and methods
// Type aliases
// Traits
@@ -0,0 +1,15 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/session"
// Values
pub fn logout() -> Unit
pub fn reload() -> Unit
// Errors
// Types and methods
// Type aliases
// Traits
@@ -0,0 +1,28 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/shortcuts"
// Values
pub fn cancel_capture() -> Unit
pub fn capture(UInt32) -> Unit
pub fn reset(UInt32) -> Unit
pub fn reset_all() -> Unit
pub fn shortcuts() -> Array[Shortcut]
// Errors
// Types and methods
pub(all) struct Shortcut {
name : String
binding : String
default_binding : String
conflict : String
capturing : Bool
}
// Type aliases
// Traits
@@ -0,0 +1,24 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/system"
// Values
pub fn read() -> Snapshot
// Errors
// Types and methods
pub(all) struct Snapshot {
cpu_permille : UInt32
mem_used_kib : UInt64
mem_total_kib : UInt64
battery_percent : Int32
charging : Bool
uptime_secs : UInt64
net_rx_bytes_per_sec : UInt64
net_tx_bytes_per_sec : UInt64
load_centi : UInt32
}
// Type aliases
// Traits
@@ -0,0 +1,23 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/wallpaper"
// Values
pub fn current_desktop() -> UInt32
pub fn current_wallpaper() -> UInt32
pub fn desktops() -> Array[String]
pub fn set_desktop(UInt32) -> Unit
pub fn set_wallpaper(UInt32) -> Unit
pub fn wallpapers() -> Array[String]
// Errors
// Types and methods
// Type aliases
// Traits
@@ -0,0 +1,32 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/windows"
// Values
pub fn all() -> Array[WindowDetail]
pub fn focus(UInt64) -> Unit
pub fn focus_window(UInt32) -> Unit
pub fn list_windows() -> Array[WindowInfo]
// Errors
// Types and methods
pub(all) struct WindowDetail {
id : UInt64
title : String
app_id : String
focused : Bool
}
pub(all) struct WindowInfo {
id : UInt32
title : String
focused : UInt32
minimized : UInt32
}
// Type aliases
// Traits
@@ -0,0 +1,23 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/host/font"
// Values
pub fn load(UInt32, String) -> Bool
pub fn rasterise(UInt32, UInt32, UInt32) -> Glyph
// Errors
// Types and methods
pub(all) struct Glyph {
width : Int32
height : Int32
xoff : Int32
yoff : Int32
advance : Int32
coverage : FixedArray[Byte]
}
// Type aliases
// Traits
+36 -30
View File
@@ -60,6 +60,12 @@ fn wasmImportPublishBattery(p0 : Int, p1 : Int, p2 : Int) = "chandra:host/plasm
///|
fn wasmImportPublishScreenshot(p0 : Int) = "chandra:host/plasmoids@0.1.0" "publish-screenshot"
///|
fn wasmImportPublishOsk(p0 : Int) = "chandra:host/plasmoids@0.1.0" "publish-osk"
///|
fn wasmImportPublishRotation(p0 : Int) = "chandra:host/plasmoids@0.1.0" "publish-rotation"
///|
fn wasmImportPublishSystem(p0 : Int, p1 : Int64, p2 : Int64, p3 : Int, p4 : Int, p5 : Int64, p6 : Int64, p7 : Int64, p8 : Int) = "chandra:host/plasmoids@0.1.0" "publish-system"
@@ -82,39 +88,17 @@ fn wasmImportPickerStart() -> Int = "chandra:host/plasmoids@0.1.0" "picker-start
fn wasmImportPickerPoll(p0 : Int) = "chandra:host/plasmoids@0.1.0" "picker-poll"
///|
#owned(bytes)
extern "wasm" fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int =
#|(func (param i32) (result i32) local.get 0)
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
#|(func (param i32) (result i32) local.get 0 i32.load)
///|
extern "wasm" fn mbt_ffi_free(position : Int) =
#|(func (param i32) local.get 0 call $moonbit.decref)
///|
extern "wasm" fn mbt_ffi_store32(offset : Int, value : Int) =
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store)
///|
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
///|
#owned(str)
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
#|(func (param i32) (result i32) local.get 0)
///|
extern "wasm" fn mbt_ffi_load64(offset : Int) -> Int64 =
#|(func (param i32) (result i64) local.get 0 i64.load)
///|
extern "wasm" fn mbt_ffi_store8(offset : Int, value : Int) =
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store8)
///|
extern "wasm" fn mbt_ffi_store64(offset : Int, value : Int64) =
#|(func (param i32) (param i64) local.get 0 local.get 1 i64.store)
///|
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
#|(func (param i32) (result i32) local.get 0 i32.load)
///|
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
#|(func (param i32) (param i32) (result i32)
@@ -130,6 +114,28 @@ extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
#| local.get 1)
///|
extern "wasm" fn mbt_ffi_free(position : Int) =
#|(func (param i32) local.get 0 call $moonbit.decref)
#owned(str)
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
#|(func (param i32) (result i32) local.get 0)
///|
extern "wasm" fn mbt_ffi_store64(offset : Int, value : Int64) =
#|(func (param i32) (param i64) local.get 0 local.get 1 i64.store)
///|
#owned(bytes)
extern "wasm" fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int =
#|(func (param i32) (result i32) local.get 0)
///|
extern "wasm" fn mbt_ffi_load64(offset : Int) -> Int64 =
#|(func (param i32) (result i64) local.get 0 i64.load)
///|
extern "wasm" fn mbt_ffi_store8(offset : Int, value : Int) =
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store8)
///|
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
@@ -100,6 +100,16 @@ fn wasmImportPublishScreenshot(p0 : Int) -> Unit {
abort("wasm-only host import")
}
///|
fn wasmImportPublishOsk(p0 : Int) -> Unit {
abort("wasm-only host import")
}
///|
fn wasmImportPublishRotation(p0 : Int) -> Unit {
abort("wasm-only host import")
}
///|
fn wasmImportPublishSystem(p0 : Int, p1 : Int64, p2 : Int64, p3 : Int, p4 : Int, p5 : Int64, p6 : Int64, p7 : Int64, p8 : Int) -> Unit {
abort("wasm-only host import")
@@ -136,7 +146,12 @@ fn wasmImportPickerPoll(p0 : Int) -> Unit {
}
///|
fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int {
fn mbt_ffi_load32(offset : Int) -> Int {
abort("wasm-only")
}
///|
fn mbt_ffi_free(position : Int) -> Unit {
abort("wasm-only")
}
@@ -145,36 +160,6 @@ fn mbt_ffi_store32(offset : Int, value : Int) -> Unit {
abort("wasm-only")
}
///|
fn mbt_ffi_load8_u(offset : Int) -> Int {
abort("wasm-only")
}
///|
fn mbt_ffi_str2ptr(str : String) -> Int {
abort("wasm-only")
}
///|
fn mbt_ffi_load64(offset : Int) -> Int64 {
abort("wasm-only")
}
///|
fn mbt_ffi_store8(offset : Int, value : Int) -> Unit {
abort("wasm-only")
}
///|
fn mbt_ffi_store64(offset : Int, value : Int64) -> Unit {
abort("wasm-only")
}
///|
fn mbt_ffi_load32(offset : Int) -> Int {
abort("wasm-only")
}
///|
fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String {
abort("wasm-only")
@@ -186,6 +171,31 @@ fn mbt_ffi_malloc(size : Int) -> Int {
}
///|
fn mbt_ffi_free(position : Int) -> Unit {
fn mbt_ffi_str2ptr(str : String) -> Int {
abort("wasm-only")
}
///|
fn mbt_ffi_store64(offset : Int, value : Int64) -> Unit {
abort("wasm-only")
}
///|
fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int {
abort("wasm-only")
}
///|
fn mbt_ffi_load64(offset : Int) -> Int64 {
abort("wasm-only")
}
///|
fn mbt_ffi_store8(offset : Int, value : Int) -> Unit {
abort("wasm-only")
}
///|
fn mbt_ffi_load8_u(offset : Int) -> Int {
abort("wasm-only")
}
@@ -31,11 +31,15 @@ pub fn popup(UInt32) -> PopupSurface?
pub fn publish_battery(Int32, UInt32, UInt32) -> Unit
pub fn publish_brightness(Int32) -> Unit
pub fn publish_desktop(Int32) -> Unit
pub fn publish_osk(Bool) -> Unit
pub fn publish_power(UInt32, UInt32) -> Unit
pub fn publish_brightness(Int) -> Unit
pub fn publish_rotation(UInt32) -> Unit
pub fn publish_screenshot(UInt32) -> Unit
@@ -133,6 +137,8 @@ pub(all) enum Request {
FaceUnlock(Int32)
GameLibrary(GameRequest)
SetBrightness(Int32)
SetOskVisible(Bool)
SetRotation(Int32)
}
pub(all) struct SettingChange {
+24
View File
@@ -70,6 +70,8 @@ pub(all) enum Request {
FaceUnlock(Int)
GameLibrary(GameRequest)
SetBrightness(Int)
SetOskVisible(Bool)
SetRotation(Int)
}
///|
/// A native file-chooser dialog (zenity on the host session) for "Add widget".
@@ -504,6 +506,20 @@ pub fn publish_screenshot(state : UInt) -> Unit {
wasmImportPublishScreenshot((state).reinterpret_as_int());
}
///|
/// Whether the built-in on-screen keyboard is currently visible.
pub fn publish_osk(visible : Bool) -> Unit {
wasmImportPublishOsk((if visible { 1 } else { 0 }));
}
///|
/// Current display orientation (0 = 0°, 1 = 90° CW, 2 = 180°, 3 = 270° CW).
pub fn publish_rotation(rot : UInt) -> Unit {
wasmImportPublishRotation((rot).reinterpret_as_int());
}
///|
pub fn publish_system(s : SystemSnapshot) -> Unit {
@@ -659,6 +675,14 @@ pub fn next_request() -> Request? {
Request::SetBrightness(mbt_ffi_load32((return_area) + 8))
}
23 => {
Request::SetOskVisible((mbt_ffi_load8_u((return_area) + 8) != 0))
}
24 => {
Request::SetRotation(mbt_ffi_load32((return_area) + 8))
}
_ => panic()
}
@@ -0,0 +1,141 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/host/raster"
// Values
pub fn capture(Int32, Int32, Int32, Int32, Int32, Int32) -> UInt32
pub fn emoji_font() -> Result[String, String]
pub fn emoji_has(Array[String]) -> Array[Bool]
pub fn emoji_image(String, Int32) -> UInt32
pub fn export_memfd() -> Int32
pub fn grab_recording_frame(Int32, Int32, Int32, Int32, Bool, Int32, Int32) -> Bool
pub fn image_pixels(Int32, Int32, FixedArray[Byte], UInt32) -> UInt32
pub fn load_image(String) -> UInt32
pub fn read_frame() -> FixedArray[Byte]
pub fn release(UInt32) -> Unit
pub fn send_recording_frame(Int32) -> Int32
pub fn snapshot_frame() -> Bool
pub fn snapshot_pixels(Int32, Int32, Int32, Int32, Int32, Int32) -> FixedArray[Byte]
pub fn snapshot_png(Int32, Int32, Int32, Int32) -> FixedArray[Byte]
pub fn submit(Frame) -> Unit
pub fn thumbnail(UInt32, Int32, Int32, UInt32) -> UInt32
pub fn write_frame_png(String) -> Bool
// Errors
// Types and methods
pub(all) struct Color {
r : Byte
g : Byte
b : Byte
a : Byte
}
pub(all) struct Disc {
cx : Int32
cy : Int32
radius : Int32
color : Color
filled : Bool
}
pub(all) struct Fill {
area : Rect
color : Color
radius : Int32
}
pub(all) struct Frame {
width : Int32
height : Int32
wallpaper : Array[Op]?
background : Array[Op]
windows : Array[Window]
panel : Array[Op]
popups : Array[Popup]
}
pub(all) struct Label {
x : Int32
y : Int32
text : String
size : Int32
color : Color
align : Byte
bold : Bool
mono : Bool
}
pub(all) enum Op {
FillRect(Fill)
StrokeRect(Stroke)
DrawLine(Segment)
DrawCircle(Disc)
DrawText(Label)
PushClip(Rect)
PopClip
DrawImage(Picture)
}
pub(all) struct Picture {
area : Rect
image : UInt32
}
pub(all) struct Popup {
area : Rect
surface : UInt32
}
pub(all) struct Rect {
x : Int32
y : Int32
w : Int32
h : Int32
}
pub(all) struct Segment {
x0 : Int32
y0 : Int32
x1 : Int32
y1 : Int32
color : Color
width : Int32
}
pub(all) struct Stroke {
area : Rect
color : Color
width : Int32
radius : Int32
}
pub(all) struct Window {
geometry : Rect
inset_top : Int32
inset_right : Int32
inset_bottom : Int32
inset_left : Int32
deco : Array[Op]
fullscreen : Bool
surface : UInt32
}
// Type aliases
// Traits
@@ -42,9 +42,9 @@ pub fn sleep_ms(Int32) -> Unit
pub fn spawn(String, String) -> Bool
pub fn spawn_socket(String) -> Int
pub fn spawn_socket(String) -> Int32
pub fn spawn_watch(String, String) -> Int
pub fn spawn_watch(String, String) -> Int32
pub fn take_fd(Int32) -> Int32