From 18fd4756d8a582980e2befe84cceb9947b45544a Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Mon, 6 May 2024 13:59:51 -0400 Subject: [PATCH 1/2] main: Add new "presentation" mode In some kiosk scenarios, the running service doesn't need a full fledged display server, but instead could get away with plymouth in a sort of "billboard" mode, where it lets the user know the service is running, but doesn't need to give any sort of indication on progress. This commit adds a new mode for this purpose (called "presentation" mode). In order to provide backward compatibility, it immediately tells the splash plugin to become idle once being displayed. For many cases, this should be a good enough experience out of the box. (and other cases can just extend their splash plugin to have specific support for the presentation mode). --- .../ply-boot-splash-plugin.h | 3 +- src/main.c | 41 ++++++++++++------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/libply-splash-core/ply-boot-splash-plugin.h b/src/libply-splash-core/ply-boot-splash-plugin.h index d5cd05a7..733480e3 100644 --- a/src/libply-splash-core/ply-boot-splash-plugin.h +++ b/src/libply-splash-core/ply-boot-splash-plugin.h @@ -43,8 +43,9 @@ typedef enum PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE, PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE, PLY_BOOT_SPLASH_MODE_SYSTEM_RESET, + PLY_BOOT_SPLASH_MODE_PRESENTATION, PLY_BOOT_SPLASH_MODE_INVALID, - PLY_BOOT_SPLASH_MODE_COUNT = PLY_BOOT_SPLASH_MODE_SYSTEM_RESET + 1, + PLY_BOOT_SPLASH_MODE_COUNT = PLY_BOOT_SPLASH_MODE_INVALID, } ply_boot_splash_mode_t; typedef struct _ply_boot_splash_plugin ply_boot_splash_plugin_t; diff --git a/src/main.c b/src/main.c index 33fe51e0..a198c8bd 100644 --- a/src/main.c +++ b/src/main.c @@ -216,6 +216,8 @@ on_change_mode (state_t *state, state->mode = PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE; else if (strcmp (mode, "system-reset") == 0) state->mode = PLY_BOOT_SPLASH_MODE_SYSTEM_RESET; + else if (strcmp (mode, "presentation") == 0) + state->mode = PLY_BOOT_SPLASH_MODE_PRESENTATION; else return; @@ -232,6 +234,9 @@ on_change_mode (state_t *state, ply_trace ("failed to update splash"); return; } + + if (state->mode == PLY_BOOT_SPLASH_MODE_PRESENTATION) + become_idle (state); } static void @@ -699,6 +704,7 @@ get_cache_file_for_mode (ply_boot_splash_mode_t mode) case PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE: case PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE: case PLY_BOOT_SPLASH_MODE_SYSTEM_RESET: + case PLY_BOOT_SPLASH_MODE_PRESENTATION: filename = NULL; break; case PLY_BOOT_SPLASH_MODE_INVALID: @@ -734,6 +740,7 @@ get_log_file_for_state (state_t *state) case PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE: case PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE: case PLY_BOOT_SPLASH_MODE_SYSTEM_RESET: + case PLY_BOOT_SPLASH_MODE_PRESENTATION: filename = _PATH_DEVNULL; break; case PLY_BOOT_SPLASH_MODE_INVALID: @@ -762,6 +769,7 @@ get_log_spool_file_for_mode (ply_boot_splash_mode_t mode) case PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE: case PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE: case PLY_BOOT_SPLASH_MODE_SYSTEM_RESET: + case PLY_BOOT_SPLASH_MODE_PRESENTATION: filename = NULL; break; case PLY_BOOT_SPLASH_MODE_INVALID: @@ -1342,6 +1350,21 @@ on_boot_splash_idle (state_t *state) state->splash_is_becoming_idle = false; } +static void +become_idle (state_t *state) +{ + if (state->splash_is_becoming_idle) + return; + + ply_trace ("becoming idle"); + + ply_boot_splash_become_idle (state->boot_splash, + (ply_boot_splash_on_idle_handler_t) + on_boot_splash_idle, + state); + state->splash_is_becoming_idle = true; +} + static void on_deactivate (state_t *state, ply_trigger_t *deactivate_trigger) @@ -1369,13 +1392,7 @@ on_deactivate (state_t *state, ply_device_manager_deactivate_keyboards (state->device_manager); if (state->boot_splash != NULL) { - if (!state->splash_is_becoming_idle) { - ply_boot_splash_become_idle (state->boot_splash, - (ply_boot_splash_on_idle_handler_t) - on_boot_splash_idle, - state); - state->splash_is_becoming_idle = true; - } + become_idle (state); } else { ply_trace ("deactivating splash"); deactivate_splash (state); @@ -1451,13 +1468,7 @@ on_quit (state_t *state, dump_details_and_quit_splash (state); quit_program (state); } else if (state->boot_splash != NULL) { - if (!state->splash_is_becoming_idle) { - ply_boot_splash_become_idle (state->boot_splash, - (ply_boot_splash_on_idle_handler_t) - on_boot_splash_idle, - state); - state->splash_is_becoming_idle = true; - } + become_idle (state); } else { quit_program (state); } @@ -2419,6 +2430,8 @@ main (int argc, state.mode = PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE; else if (strcmp (mode_string, "system-reset") == 0) state.mode = PLY_BOOT_SPLASH_MODE_SYSTEM_RESET; + else if (strcmp (mode_string, "presentation") == 0) + state.mode = PLY_BOOT_SPLASH_MODE_PRESENTATION; else state.mode = PLY_BOOT_SPLASH_MODE_BOOT_UP; From 25f8a4b4203ca6ab8bc6ce0fccd1d512af67ed9f Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Mon, 6 May 2024 14:08:53 -0400 Subject: [PATCH 2/2] client: Update to support new "presentation" mode Now that plymouthd supports a presentation mode, it would be good if there was actually a way to turn it on. This commit updates the plymouth client to allow for that. --- src/client/plymouth.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/client/plymouth.c b/src/client/plymouth.c index 82f7d920..9b3fbd90 100644 --- a/src/client/plymouth.c +++ b/src/client/plymouth.c @@ -812,6 +812,7 @@ on_change_mode_request (state_t *state, bool system_upgrade = false; bool firmware_upgrade = false; bool system_reset = false; + bool presentation = false; const char *mode = NULL; ply_command_parser_get_command_options (state->command_parser, @@ -823,6 +824,7 @@ on_change_mode_request (state_t *state, "system-upgrade", &system_upgrade, "firmware-upgrade", &firmware_upgrade, "system-reset", &system_reset, + "presentation", &presentation, NULL); if (boot_up) @@ -839,6 +841,8 @@ on_change_mode_request (state_t *state, mode = "firmware-upgrade"; else if (system_reset) mode = "system-reset"; + else if (presentation) + mode = "presentation"; if (mode) { ply_boot_client_change_mode (state->client, mode, @@ -936,6 +940,8 @@ main (int argc, PLY_COMMAND_OPTION_TYPE_FLAG, "system-reset", "Resetting the OS and erasing all user data", PLY_COMMAND_OPTION_TYPE_FLAG, + "presentation", "Display static banner without progress indication", + PLY_COMMAND_OPTION_TYPE_FLAG, NULL); ply_command_parser_add_command (state.command_parser,