diff --git a/packages/ghaf-audio-control/src/app/App.cpp b/packages/ghaf-audio-control/src/app/App.cpp index a389dfa..2d9557d 100644 --- a/packages/ghaf-audio-control/src/app/App.cpp +++ b/packages/ghaf-audio-control/src/app/App.cpp @@ -23,9 +23,9 @@ constexpr auto IconSize = 64; struct AppArgs { Glib::ustring pulseServerAddress; - Glib::ustring indicatorIconPath; + Glib::ustring indicatorIconName; Glib::ustring appVms; - bool isDeamonMode = false; + Glib::ustring isDeamonMode; }; std::vector GetAppVmsList(const std::string& appVms) @@ -41,14 +41,13 @@ std::vector GetAppVmsList(const std::string& appVms) return result; } -std::optional GetThemeIcon() +std::optional GetThemeIcon(const Glib::ustring& iconName) { auto icon_theme = Gtk::IconTheme::get_default(); - if (auto iconInfo = icon_theme->lookup_icon(IconName, IconSize, Gtk::ICON_LOOKUP_USE_BUILTIN)) + if (auto iconInfo = icon_theme->lookup_icon(iconName, IconSize, Gtk::ICON_LOOKUP_USE_BUILTIN)) return iconInfo.get_filename().c_str(); - Logger::error("App::getThemeIcon: couldn't found an icon"); return std::nullopt; } @@ -79,9 +78,9 @@ App::App(int argc, char** argv) pulseServerOption.set_long_name("pulseaudio_server"); pulseServerOption.set_description("PulseAudio server address"); - Glib::OptionEntry indicatorIconPathOption; - indicatorIconPathOption.set_long_name("indicator_icon_path"); - indicatorIconPathOption.set_description("Tray's icon indicator path"); + Glib::OptionEntry indicatorIconNameOption; + indicatorIconNameOption.set_long_name("indicator_icon_name"); + indicatorIconNameOption.set_description("Tray's icon indicator name"); Glib::OptionEntry appVmsOption; appVmsOption.set_long_name("app_vms"); @@ -93,7 +92,7 @@ App::App(int argc, char** argv) Glib::OptionGroup options("Main", "Main"); options.add_entry(pulseServerOption, appArgs.pulseServerAddress); - options.add_entry(indicatorIconPathOption, appArgs.indicatorIconPath); + options.add_entry(indicatorIconNameOption, appArgs.indicatorIconName); options.add_entry(appVmsOption, appArgs.appVms); options.add_entry(deamonModeOption, appArgs.isDeamonMode); @@ -106,6 +105,11 @@ App::App(int argc, char** argv) throw std::runtime_error{"Couldn't parse the command line arguments"}; } + Logger::info("Parsed the option: '{}' = '{}'", pulseServerOption.get_long_name().c_str(), appArgs.pulseServerAddress.c_str()); + Logger::info("Parsed the option: '{}' = '{}'", indicatorIconNameOption.get_long_name().c_str(), appArgs.indicatorIconName.c_str()); + Logger::info("Parsed the option: '{}' = '{}'", appVmsOption.get_long_name().c_str(), appArgs.appVms.c_str()); + Logger::info("Parsed the option: '{}' = '{}'", deamonModeOption.get_long_name().c_str(), appArgs.isDeamonMode.c_str()); + m_connections += signal_command_line().connect( [this]([[maybe_unused]] const Glib::RefPtr& args) { @@ -114,11 +118,13 @@ App::App(int argc, char** argv) }, false); - if (const auto iconPath = GetThemeIcon()) + if (const auto iconPath = GetThemeIcon(appArgs.indicatorIconName)) { Logger::info("Got icon path for the indicator: {}", iconPath->c_str()); app_indicator_set_icon(m_indicator.get(), iconPath->filename().c_str()); } + else + Logger::info("Couldn't found an icon for indicator: {}", appArgs.indicatorIconName.c_str()); m_audioControl = std::make_unique(std::make_unique(appArgs.pulseServerAddress), GetAppVmsList(appArgs.appVms)); diff --git a/packages/ghaf-audio-control/src/app/main.cpp b/packages/ghaf-audio-control/src/app/main.cpp index e304f89..37ad2f9 100644 --- a/packages/ghaf-audio-control/src/app/main.cpp +++ b/packages/ghaf-audio-control/src/app/main.cpp @@ -5,8 +5,6 @@ #include "App.hpp" -#include - using namespace ghaf::AudioControl; int main(int argc, char** argv)