diff --git a/src/wcm.cpp b/src/wcm.cpp index 21b96b4..6517001 100644 --- a/src/wcm.cpp +++ b/src/wcm.cpp @@ -1309,6 +1309,11 @@ WCM::WCM(Glib::RefPtr app) wf_shell_config_file = value; return true; }, "shell-config", 's', "wf-shell config file to use", "file"); + app->add_main_option_entry([this] (const Glib::ustring &, const Glib::ustring & value, bool) + { + start_plugin = value; + return true; + }, "plugin", 'p', "plugin to open at launch, or none for default", "name"); app->signal_startup().connect([this, app] () { @@ -1577,6 +1582,11 @@ void WCM::create_main_layout() global_layout.pack_start(left_stack, false, false); global_layout.pack_start(main_stack, true, true); window->add(global_layout); + if (!start_plugin.empty()) { + Plugin* launch_plugin = find_plugin_by_name(plugins,start_plugin); + std::cout << "Opening Plugin: " << start_plugin << std::endl; + this->open_page(launch_plugin); + } } void WCM::open_page(Plugin *plugin) @@ -1735,6 +1745,20 @@ void update_compound_from_section(wf::config::compound_option_t *compound, compound->set_value_untyped(value); } +Plugin*WCM::find_plugin_by_name(std::vector plugins, std::string search_name) +{ + auto it = std::find_if(plugins.begin(), plugins.end(), + [&search_name](const Plugin* plugin) { + return plugin->name == search_name; // Compare the plugin name + }); + + if (it != plugins.end()) + { + return *it; // Return the found Plugin pointer + } + std::cout << "plugin not found, name invalid" << std::endl; + return nullptr; // Return nullptr if not found +} /** * Save the given configuration to the given file. * diff --git a/src/wcm.hpp b/src/wcm.hpp index e9ef44e..d75478b 100644 --- a/src/wcm.hpp +++ b/src/wcm.hpp @@ -314,6 +314,7 @@ class WCM wf::config::config_manager_t wf_shell_config_mgr; std::string wf_config_file; std::string wf_shell_config_file; + std::string start_plugin; std::vector plugins; Plugin *current_plugin = nullptr; @@ -395,4 +396,5 @@ class WCM bool lock_input(Gtk::Dialog *grab_dialog); void unlock_input(); + Plugin *find_plugin_by_name(std::vector plugins, std::string search_name); };