Kiosk: --kiosk-hybrid keeps the desktop and locks only leaving the session
CI / test (push) Successful in 3m49s

Panel, launcher, dock, desktop module and shortcuts stay; Log out and power
actions are refused while locked. Admin escape and chandra-ctl kiosk work as
in the strict kiosk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hgvjzw8hHirxRsXSsE
This commit is contained in:
Claude committed 2026-11-26 02:38:02 +00:00
1 parent f0c39757d7
commit b4f7149c72
7 files changed
+115 -15

No files matched your search

+38 -7
View File
@@ -10,6 +10,11 @@
/// never showed one. An app that keeps dying soon after it starts is started with a growing
/// delay (1 s, 2 s, 4 s ... up to 30 s).
///
/// **Hybrid** (`--kiosk-hybrid`): a full desktop that can't be left. The panel, the launcher, the
/// dock, the desktop module (an icon desktop, a game library) and the shortcuts all work and
/// windows are laid out as usual; only leaving is locked: Log out and the power actions (suspend,
/// restart, power off) are refused with a notice. CMD is still started and restarted.
///
/// The admin escape Ctrl+Alt+Shift+Escape unlocks the kiosk (the panel, shortcuts and menus come
/// back, windows can leave fullscreen) and locks it again. `chandra-ctl kiosk lock|unlock|status`
/// does the same from a script.
@@ -23,6 +28,8 @@ pub let kiosk_quick_exit_ms : UInt64 = 10000UL
///| The kiosk's state. `cmd` is what it runs; the rest is the respawn bookkeeping.
pub(all) struct Kiosk {
cmd : String
/// Hybrid: the desktop stays (panel, desktop module, shortcuts); only leaving it is locked.
hybrid : Bool
mut locked : Bool
/// When the app was last started (0: never).
mut started_at : UInt64
@@ -37,8 +44,8 @@ pub(all) struct Kiosk {
}
///|
pub fn Kiosk::new(cmd : String) -> Kiosk {
{ cmd, locked: true, started_at: 0UL, seen_window: false, gone_at: 0UL, fails: 0, starts: 0 }
pub fn Kiosk::new(cmd : String, hybrid? : Bool = false) -> Kiosk {
{ cmd, hybrid, locked: true, started_at: 0UL, seen_window: false, gone_at: 0UL, fails: 0, starts: 0 }
}
///| Delay before starting again after `fails` failed starts in a row.
@@ -107,12 +114,12 @@ pub fn Kiosk::waiting(self : Kiosk, has_window : Bool) -> Bool {
}
///| Turn kiosk mode on: lock the shell down and start `cmd` (if any) on the next step.
pub fn ChandraCompositor::start_kiosk(self : ChandraCompositor, cmd : String) -> Unit {
self.kiosk = Some(Kiosk::new(cmd))
pub fn ChandraCompositor::start_kiosk(self : ChandraCompositor, cmd : String, hybrid? : Bool = false) -> Unit {
self.kiosk = Some(Kiosk::new(cmd, hybrid~))
self.apply_kiosk_lock()
}
///| Whether the kiosk is on and locked.
///| Whether the kiosk is on and locked (either kind: leaving the session is refused).
pub fn ChandraCompositor::kiosk_locked(self : ChandraCompositor) -> Bool {
match self.kiosk {
Some(k) => k.locked
@@ -120,6 +127,30 @@ pub fn ChandraCompositor::kiosk_locked(self : ChandraCompositor) -> Bool {
}
}
///| Whether a single-app kiosk is locked: no panel, no shortcuts or menus, windows fullscreen.
/// False for a hybrid kiosk, which keeps the desktop.
pub fn ChandraCompositor::kiosk_strict(self : ChandraCompositor) -> Bool {
match self.kiosk {
Some(k) => k.locked && !k.hybrid
None => false
}
}
///| A locked kiosk refuses to end the session: Log out and suspend / restart / power off.
/// True when `action` was refused (a notice says so).
fn ChandraCompositor::kiosk_refuses(self : ChandraCompositor, action : @shell.ShellAction) -> Bool {
if !self.kiosk_locked() {
return false
}
match action {
Logout | SystemPower(_) => {
self.shell.say("Not available in kiosk mode")
true
}
_ => false
}
}
///| Lock (true) or unlock (false) the kiosk. False when there is no kiosk.
pub fn ChandraCompositor::set_kiosk_locked(self : ChandraCompositor, locked : Bool) -> Bool {
match self.kiosk {
@@ -138,7 +169,7 @@ pub fn ChandraCompositor::set_kiosk_locked(self : ChandraCompositor, locked : Bo
///| Make the shell and the layout follow the lock: panel shown or not, work area with or
/// without the panel's and title bars' room.
fn ChandraCompositor::apply_kiosk_lock(self : ChandraCompositor) -> Unit {
let locked = self.kiosk_locked()
let locked = self.kiosk_strict()
self.shell.hide_panel = locked
if locked {
self.shell.close_launcher()
@@ -195,7 +226,7 @@ fn ChandraCompositor::kiosk_tick(self : ChandraCompositor) -> Unit {
@sys.log("kiosk: could not start '" + k.cmd + "'")
}
}
if k.locked {
if k.locked && !k.hybrid {
self.kiosk_fullscreen_all()
}
}