From a1904e93924e338723c373f36961c1c61c01046f Mon Sep 17 00:00:00 2001 From: DMJC Date: Tue, 14 Jan 2025 23:21:11 +1030 Subject: [PATCH 1/3] Patch to add cli option for launching wcm directly to plugins. For desktop integrations. --- src/wcm.cpp | 23 +++++++++++++++++++++++ src/wcm.hpp | 2 ++ 2 files changed, 25 insertions(+) diff --git a/src/wcm.cpp b/src/wcm.cpp index 21b96b4..f51d15c 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,19 @@ 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..5a1558e 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); }; From c96733efb8f7844194f255c29d45ce4c82228c36 Mon Sep 17 00:00:00 2001 From: DMJC Date: Wed, 15 Jan 2025 03:41:37 +1030 Subject: [PATCH 2/3] Updated to remove syntax issue. --- src/wcm.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wcm.hpp b/src/wcm.hpp index 5a1558e..d75478b 100644 --- a/src/wcm.hpp +++ b/src/wcm.hpp @@ -396,5 +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); + Plugin *find_plugin_by_name(std::vector plugins, std::string search_name); }; From e34eab28c50bfcba24d946d322397a17d56eeb67 Mon Sep 17 00:00:00 2001 From: DMJC Date: Fri, 17 Jan 2025 04:29:19 +1030 Subject: [PATCH 3/3] Updated Syntax. --- src/wcm.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wcm.cpp b/src/wcm.cpp index f51d15c..6517001 100644 --- a/src/wcm.cpp +++ b/src/wcm.cpp @@ -1745,14 +1745,15 @@ 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) +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()) { + if (it != plugins.end()) + { return *it; // Return the found Plugin pointer } std::cout << "plugin not found, name invalid" << std::endl;