Closed juanolon closed 8 months ago
Hey @juanolon thanks for the PR.
You probably need to change the default
State
implementation to do something like this:
impl State<'_> {
fn with_mode() -> Self {
State {
selected: Selection::History(0),
cache: Default::default(),
pop_search: Default::default(),
scroll: Default::default(),
input_value: SearchInput {
// Some arbitrary values here but this should come from the cli args
mode: ActiveMode::Web {
modifier: "ddg".to_string(),
},
modifier_display: "ddg".to_string(),
input_display: "toto".to_string(),
pop_query: "ddg toto".to_string(),
},
exec_on_next_search: false,
plugin_matchers: PluginConfigCache::default(),
}
}
}
This should be called on start instead of State::default
to build the initial state.
You could make this take an optional ActiveMode
as parameter so it fallback to the default impl when the start mode is not provided.
Note that I have tested with web mode but this might require some tweaking to make onagre refresh the displayed entry on start if the plugin needs to display entry from pop-launcher backend.
With the last commit, it is now possible to execute onagre in the following way:
onagre "find "
or
onagre "="
Whenever a plugin match the given string, it will start directly with that plugin activated.
:heavy_check_mark: 3590d3f...f5627ad - Conventional commits check succeeded.
Hello, i have being trying to add a new parameter to onagre, so it can start right away with a plugin activated. for example:
onagre "="
would start the calculator plugin. in this way, it would be possible to map eg. super+c to the calculator in i3 or sway.As you may notice, the code is incomplete and with some extra debug prints. It is my first time programming rust. Anyway, I've got to add the parameter and initialize onagre with the given string. But the UI doesn't get updated. You will realize that I just update the state of onagre after initializing the struct (this may be not desired, as onagre need to be mutable for that). I've also tried a second approach, which sends an InputChange message to onagre directly after initialization instead of updating the state. Sadly, it doesn't work, because it seems that the channel to communicate to pop isn't yet initialized. this is the debug:
It would be really nice to get some help in this issue. Maybe there is even a better solution. Thanks