Skip to content

Commit e7f89b2

Browse files
Copilots00se
andcommitted
toggle: add Shutdown as a Quick Launch shortcut option
Add a shutdown toggle app so users can assign "Shutdown" to any Quick Launch button. On activation the user sees a confirmation dialog ("Do you want to shut down?"); confirming calls battery_ui_handle_shut_down() via the launcher task, matching the existing shutdown path used by the system settings menu. The app is registered with ProcessVisibilityQuickLaunch so it only appears in the Quick Launch app-picker, not the main app launcher. Signed-off-by: GitHub Copilot <noreply@github.com> Co-authored-by: s00se <95649696+s00se@users.noreply.github.com>
1 parent 59d150b commit e7f89b2

3 files changed

Lines changed: 79 additions & 0 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/* SPDX-FileCopyrightText: 2025 The PebbleOS Contributors */
2+
/* SPDX-License-Identifier: Apache-2.0 */
3+
4+
#include "shutdown.h"
5+
6+
#include "applib/app.h"
7+
#include "applib/ui/dialogs/actionable_dialog.h"
8+
#include "applib/ui/dialogs/dialog.h"
9+
#include "kernel/event_loop.h"
10+
#include "process_management/app_manager.h"
11+
#include "pbl/services/i18n/i18n.h"
12+
#include "resource/resource_ids.auto.h"
13+
#include "shell/normal/battery_ui.h"
14+
15+
static void prv_do_shutdown(void *data) {
16+
battery_ui_handle_shut_down();
17+
}
18+
19+
static void prv_shutdown_confirm_cb(ClickRecognizerRef recognizer, void *context) {
20+
actionable_dialog_pop((ActionableDialog *)context);
21+
launcher_task_add_callback(prv_do_shutdown, NULL);
22+
}
23+
24+
static void prv_shutdown_back_cb(ClickRecognizerRef recognizer, void *context) {
25+
actionable_dialog_pop((ActionableDialog *)context);
26+
}
27+
28+
static void prv_shutdown_click_provider(void *context) {
29+
window_single_click_subscribe(BUTTON_ID_SELECT, prv_shutdown_confirm_cb);
30+
window_single_click_subscribe(BUTTON_ID_BACK, prv_shutdown_back_cb);
31+
}
32+
33+
static void prv_main(void) {
34+
ActionableDialog *a_dialog = actionable_dialog_create("Shutdown");
35+
Dialog *dialog = actionable_dialog_get_dialog(a_dialog);
36+
37+
actionable_dialog_set_action_bar_type(a_dialog, DialogActionBarConfirm, NULL);
38+
actionable_dialog_set_click_config_provider(a_dialog, prv_shutdown_click_provider);
39+
40+
dialog_set_text_color(dialog, GColorWhite);
41+
dialog_set_background_color(dialog, GColorCobaltBlue);
42+
/// Confirmation message shown in the shutdown Quick Launch dialog.
43+
dialog_set_text(dialog, i18n_get("Do you want to shut down?", a_dialog));
44+
dialog_set_icon(dialog, RESOURCE_ID_GENERIC_QUESTION_LARGE);
45+
46+
i18n_free_all(a_dialog);
47+
48+
app_actionable_dialog_push(a_dialog);
49+
app_event_loop();
50+
}
51+
52+
const PebbleProcessMd *shutdown_toggle_get_app_info(void) {
53+
static const PebbleProcessMdSystem s_app_info = {
54+
.common = {
55+
.main_func = &prv_main,
56+
.uuid = SHUTDOWN_TOGGLE_UUID,
57+
.visibility = ProcessVisibilityQuickLaunch,
58+
},
59+
/// Name of the Shutdown Quick Launch option shown in Quick Launch settings.
60+
.name = i18n_noop("Shutdown"),
61+
};
62+
return &s_app_info.common;
63+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* SPDX-FileCopyrightText: 2025 The PebbleOS Contributors */
2+
/* SPDX-License-Identifier: Apache-2.0 */
3+
4+
#pragma once
5+
6+
#include "process_management/app_manager.h"
7+
8+
#define SHUTDOWN_TOGGLE_UUID {0x8b, 0x9a, 0x7c, 0x3e, 0x45, 0xd1, 0x4f, 0x89, \
9+
0xb2, 0x56, 0xee, 0xcc, 0xdd, 0xbb, 0xaa, 0x01}
10+
11+
const PebbleProcessMd *shutdown_toggle_get_app_info(void);

src/fw/shell/normal/system_app_registry_list.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,11 @@
574574
"enum": "AIRPLANE_MODE_TOGGLE",
575575
"md_fn": "airplane_mode_toggle_get_app_info"
576576
},
577+
{
578+
"id": -100,
579+
"enum": "SHUTDOWN_TOGGLE",
580+
"md_fn": "shutdown_toggle_get_app_info"
581+
},
577582
{
578583
"id": -96,
579584
"enum": "TIMELINE_PAST",

0 commit comments

Comments
 (0)