Autostart option (#2079)

* Autostart app on boot
* Settings page
* ext app support
This commit is contained in:
Totoo 2024-04-03 16:27:13 +02:00 committed by GitHub
parent 3665b3c607
commit c48cbb7e55
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 116 additions and 0 deletions

View file

@ -107,6 +107,10 @@
#include "file_reader.hpp"
#include "png_writer.hpp"
#include "file_path.hpp"
#include "ff.h"
#include <locale>
#include <codecvt>
using portapack::receiver_model;
using portapack::transmitter_model;
@ -708,6 +712,23 @@ bool NavigationView::set_on_pop(std::function<void()> on_pop) {
return true;
}
void NavigationView::handle_autostart() {
std::string autostart_app{""};
SettingsStore nav_setting{
"nav"sv,
{{"autostart_app"sv, &autostart_app}}};
if (!autostart_app.empty()) {
if (StartAppByName(autostart_app.c_str())) return;
// if returned false, check for external apps by that name, and try to start it
std::string appwithpath = "/" + apps_dir.string() + "/";
appwithpath += autostart_app;
appwithpath += ".ppma";
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> conv;
std::filesystem::path pth = conv.from_bytes(appwithpath.c_str());
ui::ExternalItemsMenuLoader::run_external_app(*this, pth);
}
}
/* Helpers **************************************************************/
static void add_apps(NavigationView& nav, BtnGridView& grid, app_location_t loc) {