Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch to add cli option for launching wcm directly to plugins. Resolves #93 #94

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/wcm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,11 @@ WCM::WCM(Glib::RefPtr<Gtk::Application> 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] ()
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<Plugin*> 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.
*
Expand Down
2 changes: 2 additions & 0 deletions src/wcm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Plugin*> plugins;

Plugin *current_plugin = nullptr;
Expand Down Expand Up @@ -395,4 +396,5 @@ class WCM

bool lock_input(Gtk::Dialog *grab_dialog);
void unlock_input();
Plugin *find_plugin_by_name(std::vector<Plugin*> plugins, std::string search_name);
};