From b7c1649c82f7f9bf36ac2e0e125ca2fb9ea4aef3 Mon Sep 17 00:00:00 2001 From: Vladislav Nepogodin Date: Fri, 15 Dec 2023 01:15:38 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20drivers:=20cleanup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/drivers.cpp | 64 ++++++++----------------------------------------- 1 file changed, 10 insertions(+), 54 deletions(-) diff --git a/src/drivers.cpp b/src/drivers.cpp index 05b70b5..a038f2c 100644 --- a/src/drivers.cpp +++ b/src/drivers.cpp @@ -23,40 +23,13 @@ using namespace std::string_view_literals; namespace tui { -static void install_ati() noexcept { -#ifdef NDEVENV - auto* config_instance = Config::instance(); - auto& config_data = config_instance->data(); - const auto& mountpoint = std::get(config_data["MOUNTPOINT"]); - - utils::exec(fmt::format(FMT_COMPILE("sed -i 's/MODULES=\"\"/MODULES=\"radeon\"/' {}/etc/mkinitcpio.conf"), mountpoint)); -#endif -} - -#ifdef NDEVENV -static void install_all_drivers() noexcept { - static constexpr auto packages = "xf86-input-libinput xf86-video-fbdev xf86-video-vesa xf86-video-amdgpu xf86-video-ati xf86-video-intel xf86-video-nouveau"sv; - - auto* config_instance = Config::instance(); - auto& config_data = config_instance->data(); - const auto& mountpoint = std::get(config_data["MOUNTPOINT"]); - const auto& hostcache = std::get(config_data["hostcache"]); - - if (hostcache) { - detail::follow_process_log_widget({"/bin/sh", "-c", fmt::format(FMT_COMPILE("pacstrap {} {}"), mountpoint, packages)}); - return; - } - detail::follow_process_log_widget({"/bin/sh", "-c", fmt::format(FMT_COMPILE("pacstrap -c {} {}"), mountpoint, packages)}); -} -#endif - static void setup_graphics_card() noexcept { - std::string_view driver{}; + std::string driver{}; /// TODO(vnepogodin): parse toml DBs { - static constexpr auto UseSpaceBar = "\nUse [Spacebar] to de/select options listed.\n"sv; - const auto& profile_names = ::detail::chwd::get_available_profile_names("graphic_drivers"sv); + static constexpr auto use_spacebar = "\nUse [Spacebar] to de/select options listed.\n"sv; + const auto& profile_names = ::detail::chwd::get_available_profile_names("graphic_drivers"sv); if (!profile_names.has_value()) { spdlog::error("failed to get profile names"); return; @@ -69,34 +42,24 @@ static void setup_graphics_card() noexcept { driver = radiobox_list[static_cast(selected)]; screen.ExitLoopClosure()(); }; - detail::radiolist_widget(radiobox_list, ok_callback, &selected, &screen, {.text = UseSpaceBar}, {.text_size = nothing}); + detail::radiolist_widget(radiobox_list, ok_callback, &selected, &screen, {.text = use_spacebar}, {.text_size = nothing}); } /* clang-format off */ if (driver.empty()) { return; } /* clang-format on */ - auto* config_instance = Config::instance(); - auto& config_data = config_instance->data(); - auto& graphics_card = std::get(config_data["GRAPHIC_CARD"]); + auto* config_instance = Config::instance(); + auto& config_data = config_instance->data(); + const auto& mountpoint = std::get(config_data["MOUNTPOINT"]); + const auto& cachepath = std::get(config_data["cachepath"]); #ifdef NDEVENV - const auto& mountpoint = std::get(config_data["MOUNTPOINT"]); - const auto& cachepath = std::get(config_data["cachepath"]); const auto& cmd_formatted = fmt::format(FMT_COMPILE("chwd --pmcachedir \"{}\" --pmroot {} -f -i pci {} 2>>/tmp/cachyos-install.log 2>&1"), cachepath, mountpoint, driver); tui::detail::follow_process_log_widget({"/bin/sh", "-c", cmd_formatted}); std::ofstream{fmt::format(FMT_COMPILE("{}/.video_installed"), mountpoint)}; +#else + spdlog::debug("chwd --pmcachedir \"{}\" --pmroot {} -f -i pci {} 2>>/tmp/cachyos-install.log 2>&1", cachepath, mountpoint, driver); #endif - - graphics_card = utils::exec("lspci | grep -i \"vga\" | sed 's/.*://' | sed 's/(.*//' | sed 's/^[ \\t]*//'"sv); - - // All non-NVIDIA cards / virtualization - if (!(utils::exec(fmt::format(FMT_COMPILE("echo \"{}\" | grep -i 'ati'"), graphics_card)).empty())) { - install_ati(); -#ifdef NDEVENV - } else if (driver == "video-nouveau"sv) { - utils::exec(fmt::format(FMT_COMPILE("sed -i 's/MODULES=\"\"/MODULES=\"nouveau\"/' {}/etc/mkinitcpio.conf"), mountpoint)); -#endif - } } static void install_graphics_menu() noexcept { @@ -108,7 +71,6 @@ static void install_graphics_menu() noexcept { "Auto-install free drivers", "Auto-install proprietary drivers", "Select Display Driver", - "Install all free drivers", "Back", }; @@ -129,12 +91,6 @@ static void install_graphics_menu() noexcept { case 2: setup_graphics_card(); break; -#ifdef NDEVENV - case 3: - install_all_drivers(); - std::ofstream{fmt::format(FMT_COMPILE("{}/.video_installed"), mountpoint)}; - break; -#endif default: screen.ExitLoopClosure()(); break;