Gamerig Library: gamerig's game library as a Chandra desktop module
CI / test (push) Successful in 2m25s

- New desktop module gamerig-library (components/gamerig-library, logic in lib/gamelib): the
  layout of gamerig's web library (desktop/ui) in draw ops. Top bar with the Gamerig mark, app
  count and search; sidebar with categories and counts, running apps (switch to, stop) and rig
  status (GPU, display, audio); card grid with featured games two columns wide, icon tiles,
  category and status badges, description, install hint, Launch / Big Picture / Switch to / Stop.
  Typing filters, arrows + Enter launch, the wheel scrolls. Colours: follow desktop, dark, light.
- New game-library capability: tables 26-28 (status, games, launch modes), request 45, in the
  wasmer/wasmtime stub, the MoonBit wasmhost and the Rust host-wasm.
- compositor/shell/gamelib.mbt polls GET $GAMERIG_DESKTOP_API/api/state (default
  http://127.0.0.1:8091) every 2 s with curl on a socket and POSTs launch/stop/focus; a file://
  base reads a state file (tests).
- --desktop NAME picks what fills the desktop at start. scripts/gamerig-kiosk.sh now runs a
  hybrid kiosk with the library as the desktop (CHANDRA_KIOSK_MODE=strict for the old one).
- Tests: lib/gamelib, compositor/host/gamelib_test.mbt, a host-wasm test; docs/gamerig-library.md
  with a screenshot.

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:57:07 +00:00
1 parent fa932f9ac0
commit f556df2f4b
57 files changed
+3551 -29

No files matched your search

+13
View File
@@ -335,6 +335,13 @@ pub(all) enum HostTable {
FaceStatus
/// Enrolled faces (ss: label added).
Faces
/// Game library status (ssssssii: error gpu resolution display audio hostname connected
/// audio-ok; one row), served by `game-library.status`.
GameStatus
/// Games (ssssssiii: id name category description icon install-hint featured installed running).
Games
/// Extra launch modes (sss: game id label).
GameModes
}
///|
@@ -365,6 +372,9 @@ pub fn publish(which : HostTable, t : Table) -> Unit {
Desktops => 20U
FaceStatus => 24U
Faces => 25U
GameStatus => 26U
Games => 27U
GameModes => 28U
}
// Most tables are republished every frame unchanged: skip the copy into the host then.
let slot = id.reinterpret_as_int()
@@ -455,6 +465,8 @@ pub(all) enum HostRequest {
/// The face-unlock capability: a face index removes it; -1 refresh, -2 enroll, -3 / -4 stop /
/// start using it for the password dialog and sudo.
FaceUnlock(Int)
/// The game-library capability: 0 launch (game, mode), 1 stop, 2 focus (game), 3 refresh.
GameLibrary(Int, String, String)
} derive(Eq, Debug)
///|
@@ -482,6 +494,7 @@ pub fn next_request() -> HostRequest? {
Some(ReloadSession) => Some(ReloadSession)
Some(SetDesktop(i)) => Some(SetDesktop(i))
Some(FaceUnlock(i)) => Some(FaceUnlock(i))
Some(GameLibrary(r)) => Some(GameLibrary(r.action, r.game, r.mode))
}
}
+20
View File
@@ -743,6 +743,13 @@ pub(all) enum HostTable {
FaceStatus
/// Enrolled faces (ss: label added).
Faces
/// Game library status (ssssssii: error gpu resolution display audio hostname connected
/// audio-ok; one row), served by `game-library.status`.
GameStatus
/// Games (ssssssiii: id name category description icon install-hint featured installed running).
Games
/// Extra launch modes (sss: game id label).
GameModes
}
///| Publish `t` as the data behind `which` for every module's next call.
@@ -764,6 +771,9 @@ pub fn publish(which : HostTable, t : Table) -> Unit {
Desktops => 20
FaceStatus => 24
Faces => 25
GameStatus => 26
Games => 27
GameModes => 28
}
let out : Array[Byte] = []
for k = 0; k < 4; k = k + 1 {
@@ -853,6 +863,8 @@ pub(all) enum HostRequest {
/// The face-unlock capability: a face index removes it; -1 refresh, -2 enroll, -3 / -4 stop /
/// start using it for the password dialog and sudo.
FaceUnlock(Int)
/// The game-library capability: 0 launch (game, mode), 1 stop, 2 focus (game), 3 refresh.
GameLibrary(Int, String, String)
} derive(Eq, Debug)
///|
@@ -896,6 +908,14 @@ pub fn next_request() -> HostRequest? {
19 => Some(DefaultApp(c_host_req_int()))
40 => Some(SetDesktop(c_host_req_int()))
44 => Some(FaceUnlock(c_host_req_int()))
45 => {
let code = c_host_req_int()
let s = req_str()
match s.find("\u{1f}") {
Some(i) => Some(GameLibrary(code, s[:i].to_string(), s[i + 1:].to_string()))
None => Some(GameLibrary(code, s, ""))
}
}
_ => None
}
}
+34 -2
View File
@@ -67,7 +67,8 @@ enum {
K_SC_LIST, K_SC_CAPTURE, K_SC_CANCEL, K_SC_RESET, K_SC_RESET_ALL,
K_DA_CATS, K_DA_APPS, K_DA_SET, K_DA_REFRESH,
K_DESKTOPS, K_DESKTOP_CUR, K_SET_DESKTOP,
K_FU_STATUS, K_FU_FACES, K_FU_ENROLL, K_FU_REMOVE, K_FU_SET_IN_USE, K_FU_REFRESH
K_FU_STATUS, K_FU_FACES, K_FU_ENROLL, K_FU_REMOVE, K_FU_SET_IN_USE, K_FU_REFRESH,
K_GL_STATUS, K_GL_GAMES, K_GL_MODES, K_GL_LAUNCH, K_GL_STOP, K_GL_FOCUS, K_GL_REFRESH
};
typedef struct Env { Inst *inst; int kind; } Env;
@@ -76,7 +77,8 @@ typedef struct Env { Inst *inst; int kind; } Env;
enum { T_APPS, T_WINDOWS, T_LAYOUTS, T_MODULES, T_INSTANCES, T_WALLPAPERS, T_SESSION_SETTINGS, T_ICONS,
T_NET_STATUS, T_NET_NETWORKS, T_SHORTCUTS, T_APP_CATS, T_APP_CHOICES,
/* fixed numbers from here (wit/host/plasmoids.wit publish-table) */
T_DESKTOPS = 20, T_FACE_STATUS = 24, T_FACES = 25, T_N = 32 };
T_DESKTOPS = 20, T_FACE_STATUS = 24, T_FACES = 25,
T_GL_STATUS = 26, T_GL_GAMES = 27, T_GL_MODES = 28, T_N = 32 };
typedef struct { uint8_t *data; size_t len; } Blob;
static Blob tables[T_N];
static int32_t host_ints[24] = {[7] = -1}; /* 0 layout mode, 1 inspector on, 2 current wallpaper, 3 session settings on (bit i: row i),
@@ -397,6 +399,29 @@ static wasm_trap_t *host_import(void *env, const wasm_val_vec_t *args, wasm_val_
case K_FU_REMOVE: if (a0 >= 0 && a0 < 1000) push_req(44, a0, NULL); break;
case K_FU_SET_IN_USE: push_req(44, a0 ? -4 : -3, NULL); break;
case K_FU_REFRESH: push_req(44, -1, NULL); break;
/* Game library: status from table 26 (error gpu resolution display audio hostname connected
* audio-ok), games from 27 (id name category description icon install-hint featured installed
* running), launch modes from 28 (game id label); request 45 is 0 launch / 1 stop / 2 focus /
* 3 refresh, with "game\x1fmode". */
case K_GL_STATUS: build_record(in, T_GL_STATUS, "ssssssbb", a0); break;
case K_GL_GAMES: build_list(in, T_GL_GAMES, "ssssssbbb", a0); break;
case K_GL_MODES: build_list(in, T_GL_MODES, "sss", a0); break;
case K_GL_REFRESH: push_req(45, 3, NULL); break;
case K_GL_LAUNCH:
case K_GL_STOP:
case K_GL_FOCUS: {
int32_t a3 = args->size >= 4 ? args->data[3].of.i32 : 0;
char *game = guest_str(in, a0, a1);
char *mode = e->kind == K_GL_LAUNCH ? guest_str(in, a2, a3) : strdup("");
size_t lg = strlen(game), lm = strlen(mode);
char *both = (char *)malloc(lg + lm + 2);
memcpy(both, game, lg);
both[lg] = 0x1f;
memcpy(both + lg + 1, mode, lm + 1);
push_req(45, e->kind == K_GL_LAUNCH ? 0 : e->kind == K_GL_STOP ? 1 : 2, both);
free(game); free(mode); free(both);
break;
}
case K_SESSION_SET: push_req(a1 ? 11 : 10, a0, NULL); break; /* 10 off, 11 on */
/* Request 12 carries the screenshot code: 0-3 take, 10-12 record, 20 stop, 30/31 pointer. */
case K_SHOT_TAKE: if (a0 >= 0 && a0 <= 3) push_req(12, a0, NULL); break;
@@ -620,6 +645,13 @@ static int classify_import(const wasm_name_t *m, const wasm_name_t *f) {
if (!strcmp(iface, "face-unlock") && !strcmp(fn, "remove")) return K_FU_REMOVE;
if (!strcmp(iface, "face-unlock") && !strcmp(fn, "set-in-use")) return K_FU_SET_IN_USE;
if (!strcmp(iface, "face-unlock") && !strcmp(fn, "refresh")) return K_FU_REFRESH;
if (!strcmp(iface, "game-library") && !strcmp(fn, "status")) return K_GL_STATUS;
if (!strcmp(iface, "game-library") && !strcmp(fn, "games")) return K_GL_GAMES;
if (!strcmp(iface, "game-library") && !strcmp(fn, "launch-modes")) return K_GL_MODES;
if (!strcmp(iface, "game-library") && !strcmp(fn, "launch")) return K_GL_LAUNCH;
if (!strcmp(iface, "game-library") && !strcmp(fn, "stop")) return K_GL_STOP;
if (!strcmp(iface, "game-library") && !strcmp(fn, "focus")) return K_GL_FOCUS;
if (!strcmp(iface, "game-library") && !strcmp(fn, "refresh")) return K_GL_REFRESH;
if (!strcmp(iface, "session-settings") && !strcmp(fn, "settings")) return K_SESSION_SETTINGS;
if (!strcmp(iface, "session-settings") && !strcmp(fn, "is-on")) return K_SESSION_IS_ON;
if (!strcmp(iface, "session-settings") && !strcmp(fn, "set-setting")) return K_SESSION_SET;