From 9ff974c100bc7de7e18fa4e7998170263c9fcd19 Mon Sep 17 00:00:00 2001 From: Vladislav Nepogodin Date: Sun, 9 Jan 2022 18:02:00 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20update=20virtual=20console=20sta?= =?UTF-8?q?tus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/crypto.cpp | 7 +++---- src/tui.cpp | 29 ++++++++++++++++++++++++++++- src/utils.cpp | 8 ++++++++ src/utils.hpp | 1 + 5 files changed, 41 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 628f3de..1371b18 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ TODO: should be simple as calamares Main Menu | ├── Prepare Installation -| ├── Set Virtual Console (TODO) +| ├── Set Virtual Console | ├── List Devices | ├── Partition Disk | ├── RAID (WIP) diff --git a/src/crypto.cpp b/src/crypto.cpp index 7d8d5b6..85cbebf 100644 --- a/src/crypto.cpp +++ b/src/crypto.cpp @@ -103,8 +103,6 @@ bool luks_open() noexcept { if (!tui::get_crypt_password(luks_password)) { return false; } /* clang-format on */ - spdlog::info("partition: {}, luks_root_name: {}, luks_password: {}", partition, luks_root_name, luks_password); - // Try to open the luks partition with the credentials given. If successful show this, otherwise // show the error detail::infobox_widget("\nPlease wait...\n"); @@ -207,8 +205,9 @@ void luks_menu_advanced() noexcept { screen.ExitLoopClosure()(); }; - const auto& content = fmt::format("\n{}\n \n{}\n \n{}\n", luks_menu_body, luks_menu_body2, luks_menu_body3); - detail::menu_widget(menu_entries, ok_callback, &selected, &screen, content); + const auto& content = fmt::format("\n{}\n \n{}\n \n{}\n", luks_menu_body, luks_menu_body2, luks_menu_body3); + const auto& content_size = size(HEIGHT, LESS_THAN, 10) | size(WIDTH, GREATER_THAN, 40); + detail::menu_widget(menu_entries, ok_callback, &selected, &screen, content, {.content_size = content_size}); /* clang-format off */ if (!success) { return; } diff --git a/src/tui.cpp b/src/tui.cpp index 30719b9..8d27db8 100644 --- a/src/tui.cpp +++ b/src/tui.cpp @@ -269,6 +269,32 @@ void set_xkbmap() noexcept { #endif } +void select_keymap() noexcept { + auto* config_instance = Config::instance(); + auto& config_data = config_instance->data(); + auto& keymap = std::get(config_data["KEYMAP"]); + + // does user want to change the default settings? + static constexpr auto default_keymap = "Currently configured keymap setting is:"; + const auto& content = fmt::format("\n {}\n \n[ {} ]\n", default_keymap, keymap); + const auto& keep_default = detail::yesno_widget(content, size(HEIGHT, LESS_THAN, 15) | size(WIDTH, LESS_THAN, 75)); + /* clang-format off */ + if (!keep_default) { return; } + /* clang-format on */ + + const auto& keymaps = utils::make_multiline(utils::exec("ls -R /usr/share/kbd/keymaps | grep \"map.gz\" | sed 's/\\.map\\.gz//g' | sort")); + + auto screen = ScreenInteractive::Fullscreen(); + std::int32_t selected{226}; + auto ok_callback = [&] { + keymap = keymaps[static_cast(selected)]; + screen.ExitLoopClosure()(); + }; + static constexpr auto vc_keymap_body = "\nA virtual console is a shell prompt in a non-graphical environment.\nIts keymap is independent of a desktop environment / terminal.\n"; + const auto& content_size = size(HEIGHT, GREATER_THAN, 10) | size(WIDTH, GREATER_THAN, 40) | vscroll_indicator | yframe | flex; + detail::menu_widget(keymaps, ok_callback, &selected, &screen, vc_keymap_body, {content_size, size(HEIGHT, GREATER_THAN, 1)}); +} + // Set Zone and Sub-Zone bool set_timezone() noexcept { std::string zone{}; @@ -1993,7 +2019,8 @@ void prep_menu() noexcept { auto ok_callback = [&] { switch (selected) { case 0: - SPDLOG_ERROR("Implement me!"); + tui::select_keymap(); + utils::set_keymap(); break; case 1: tui::show_devices(); diff --git a/src/utils.cpp b/src/utils.cpp index 08be3c3..9a86813 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -632,6 +632,14 @@ void show_iwctl() noexcept { } } +void set_keymap() noexcept { + auto* config_instance = Config::instance(); + auto& config_data = config_instance->data(); + const auto& keymap = std::get(config_data["KEYMAP"]); + + utils::exec(fmt::format("loadkeys {}", keymap)); +} + void parse_config() noexcept { using namespace simdjson; diff --git a/src/utils.hpp b/src/utils.hpp index 6ae02b9..6a336b6 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -38,6 +38,7 @@ void id_system() noexcept; [[nodiscard]] bool handle_connection() noexcept; void show_iwctl() noexcept; +void set_keymap() noexcept; void parse_config() noexcept; void setup_luks_keyfile() noexcept; void final_check() noexcept;