This commit is contained in:
Kirottu
2023-04-11 11:18:12 +03:00
5 changed files with 43 additions and 13 deletions

View File

@@ -11,7 +11,7 @@ A wayland native krunner-like runner, made with customizability in mind.
- Hence the name anyrun
- Easy to make plugins
- You only need 4 functions!
- See [Rink](plugins/rink) for a simple example. More info in the documentation of the [anyrun-plugin](anyrun-plugin) crate.
- See [Rink](plugins/rink) for a simple example. More info in the documentation of the [anyrun-plugin](anyrun-plugin) crate.
- Responsive
- Asynchronous running of plugin functions
- Wayland native
@@ -24,6 +24,7 @@ A wayland native krunner-like runner, made with customizability in mind.
Anyrun mainly depends various GTK libraries, and rust of course for building the project. Rust you can get with [rustup](https://rustup.rs). The rest are statically linked in the binary.
Here are the libraries you need to have to build & run it:
- `gtk-layer-shell (libgtk-layer-shell)`
- `gtk3 (libgtk-3 libgdk-3)`
- `pango (libpango-1.0)`
@@ -49,10 +50,13 @@ cp target/release/*.so ~/.config/anyrun/plugins # Copy all of the built plugins
```
After that you need to create the configuration file and place it in `~/.config/anyrun/config.ron`. A config file with all of the included plugins is as follows:
```ron
Config(
width: 800,
position: Top,
hide_icons: false,
hide_plugin_info: false,
plugins: [
"libapplications.so",
"libsymbols.so",
@@ -62,7 +66,6 @@ Config(
)
```
## Plugins
Anyrun requires plugins to function, as they provide the results for input. The list of plugins in this repository is as follows:
@@ -94,10 +97,13 @@ The default configuration directory is `$HOME/.config/anyrun` the structure of t
```
The config file has the following structure, and as seen in the name uses the `ron` language:
```ron
Config(
width: 800, // The width of the window
position: Top,
hide_icons: false,
hide_plugin_info: false,
plugins: [
"libapplications.so", // Relative paths are looked up in the <config dir>/plugins/ directory
"/home/kirottu/Projects/anyrun/target/debug/libsymbols.so", // Absolute paths are well, asbolute and loaded as is. Useful for development.
@@ -141,6 +147,7 @@ The custom arguments for anyrun are as follows:
The plugin API is intentionally very simple to use. This is all you need for a plugin:
`Cargo.toml`:
```toml
#[package] omitted
[lib]
@@ -153,6 +160,7 @@ abi_stable = "0.11.1"
```
`lib.rs`:
```rs
use abi_stable::std_types::{RString, RVec, ROption};
use anyrun_plugin::{plugin, PluginInfo, Match, HandleResult};
@@ -171,7 +179,7 @@ fn info() -> PluginInfo {
fn get_matches(input: RString, data: &mut ()) -> RVec<Match> {
// The logic to get matches from the input text in the `input` argument.
// The `data` is a mutable reference to the shared data type later specified.
// The `data` is a mutable reference to the shared data type later specified.
vec![Match {
title: "Test match".into(),
icon: ROption::RSome("help-about"),

View File

@@ -19,6 +19,7 @@ struct Config {
plugins: Vec<PathBuf>,
position: Position,
hide_icons: bool,
hide_plugin_info: bool,
}
/// A "view" of plugin's info and matches
@@ -250,13 +251,15 @@ fn activate(app: &gtk::Application, runtime_data: Rc<RefCell<Option<RuntimeData>
.spacing(10)
.name(style_names::PLUGIN)
.build();
plugin_box.add(&create_info_box(&plugin.info()(), config.hide_icons));
plugin_box.add(
&gtk::Separator::builder()
.orientation(gtk::Orientation::Horizontal)
.name(style_names::PLUGIN)
.build(),
);
if !config.hide_plugin_info {
plugin_box.add(&create_info_box(&plugin.info()(), config.hide_icons));
plugin_box.add(
&gtk::Separator::builder()
.orientation(gtk::Orientation::Horizontal)
.name(style_names::PLUGIN)
.build(),
);
}
let list = gtk::ListBox::builder()
.name(style_names::PLUGIN)
.hexpand(true)

View File

@@ -0,0 +1,13 @@
# Applications
## Desktop Actions
To enable desktop actions support, set `desktop_actions` in the applications plugin config
file to `true` like so:
`<anyrun config directory>/applications.ron`:
```ron
Config(
desktop_actions: true,
)
```

View File

@@ -31,11 +31,15 @@ impl DesktopEntry {
let mut line = None;
let mut new_sections = Vec::new();
for section in sections.iter() {
for (i, section) in sections.iter().enumerate() {
if let Some(line) = line {
let mut section = section.to_vec();
section.insert(0, line);
section.pop();
// Only pop the last redundant entry if it isn't the last item
if i < sections.len() - 1 {
section.pop();
}
new_sections.push(section);
}
line = Some(section.last().unwrap_or(&""));

View File

@@ -1,4 +1,6 @@
# User defined symbols
# Symbols
## User defined symbols
User defined symbols are defined in the `symbols.ron` file inside the anyrun configuration directory. The structure of the file is as follows:
```ron