Compare commits

4 Commits

Author SHA1 Message Date
Kirottu
06017e753c [Stdin] Added configuration file documentation 2024-12-27 14:04:11 +02:00
Dokkae
7f40aaa02f Support KP_Enter as selection key (#174)
This commit adds selection/action support for the numpad enter key
2024-12-26 15:53:00 +02:00
Kirottu
27b5a1904a [Applications] Reworked terminal configuration to allow for more terminal possibilities 2024-12-26 15:35:33 +02:00
Myshko Dm
6bdba4377b chore: update links (#204) 2024-12-26 15:30:37 +02:00
7 changed files with 86 additions and 21 deletions

View File

@@ -173,8 +173,8 @@ Make sure all of the dependencies are installed, and then run the following
commands in order:
```bash
# Clone the repository and move to the cloned location
git clone https://github.com/Kirottu/anyrun.git && cd anyrun
# Clone the repository and move to the cloned location
git clone https://github.com/anyrun-org/anyrun && cd anyrun
# Build all packages, and install the Anyrun binary
cargo build --release
@@ -287,7 +287,7 @@ plugin:
crate-type = ["cdylib"] # Required to build a dynamic library that can be loaded by anyrun
[dependencies]
anyrun-plugin = { git = "https://github.com/Kirottu/anyrun" }
anyrun-plugin = { git = "https://github.com/anyrun-org/anyrun" }
abi_stable = "0.11.1"
# Any other dependencies you may have
```

View File

@@ -565,7 +565,7 @@ fn activate(app: &gtk::Application, runtime_data: Rc<RefCell<RuntimeData>>) {
Inhibit(true)
}
// Handle when the selected match is "activated"
constants::Return => {
constants::Return | constants::KP_Enter => {
let mut _runtime_data_clone = runtime_data_clone.borrow_mut();
let (selected_match, plugin_view) = match _runtime_data_clone

View File

@@ -81,7 +81,7 @@ in
meta = {
description = "A wayland native, highly customizable runner.";
homepage = "https://github.com/Kirottu/anyrun";
homepage = "https://github.com/anyrun-org/anyrun";
license = [lib.licenses.gpl3];
mainProgram = "anyrun";
maintainers = with lib.maintainers; [NotAShelf n3oney];

View File

@@ -65,7 +65,7 @@ in
meta = {
description = "The ${name} plugin for Anyrun";
homepage = "https://github.com/Kirottu/anyrun";
homepage = "https://github.com/anyrun-org/anyrun";
license = [lib.licenses.gpl3];
maintainers = with lib.maintainers; [NotAShelf n3oney];
};

View File

@@ -18,6 +18,12 @@ Config(
max_entries: 5,
// The terminal used for running terminal based desktop entries, if left as `None` a static list of terminals is used
// to determine what terminal to use.
terminal: Some("alacritty"),
terminal: Some(Terminal(
// The main terminal command
command: "alacritty",
// What arguments should be passed to the terminal process to run the command correctly
// {} is replaced with the command in the desktop entry
args: "-e {}",
)),
)
```
```

View File

@@ -9,7 +9,13 @@ use std::{env, fs, process::Command};
pub struct Config {
desktop_actions: bool,
max_entries: usize,
terminal: Option<String>,
terminal: Option<Terminal>,
}
#[derive(Deserialize)]
pub struct Terminal {
command: String,
args: String,
}
impl Default for Config {
@@ -29,8 +35,6 @@ pub struct State {
mod scrubber;
const SENSIBLE_TERMINALS: &[&str] = &["alacritty", "foot", "kitty", "wezterm", "wterm"];
#[handler]
pub fn handler(selection: Match, state: &State) -> HandleResult {
let entry = state
@@ -48,18 +52,58 @@ pub fn handler(selection: Match, state: &State) -> HandleResult {
if entry.term {
match &state.config.terminal {
Some(term) => {
if let Err(why) = Command::new(term).arg("-e").arg(&entry.exec).spawn() {
if let Err(why) = Command::new("sh")
.arg("-c")
.arg(format!(
"{} {}",
term.command,
term.args.replace("{}", &entry.exec)
))
.spawn()
{
eprintln!("Error running desktop entry: {}", why);
}
}
None => {
for term in SENSIBLE_TERMINALS {
if Command::new(term)
.arg("-e")
.arg(&entry.exec)
.spawn()
.is_ok()
let sensible_terminals = &[
Terminal {
command: "alacritty".to_string(),
args: "-e {}".to_string(),
},
Terminal {
command: "foot".to_string(),
args: "-e \"{}\"".to_string(),
},
Terminal {
command: "kitty".to_string(),
args: "-e \"{}\"".to_string(),
},
Terminal {
command: "wezterm".to_string(),
args: "-e \"{}\"".to_string(),
},
Terminal {
command: "wterm".to_string(),
args: "-e \"{}\"".to_string(),
},
];
for term in sensible_terminals {
if Command::new("which")
.arg(&term.command)
.output()
.is_ok_and(|output| output.status.success())
{
if let Err(why) = Command::new("sh")
.arg("-c")
.arg(format!(
"{} {}",
term.command,
term.args.replace("{}", &entry.exec)
))
.spawn()
{
eprintln!("Error running desktop entry: {}", why);
}
break;
}
}
@@ -72,13 +116,16 @@ pub fn handler(selection: Match, state: &State) -> HandleResult {
.arg("-c")
.arg(&entry.exec)
.current_dir(if let Some(path) = &entry.path {
if path.exists() { path } else { current_dir }
if path.exists() {
path
} else {
current_dir
}
} else {
current_dir
})
.spawn()
}
{
} {
eprintln!("Error running desktop entry: {}", why);
}

View File

@@ -7,3 +7,15 @@ Allows for easy integration into scripts that have been made with something like
This plugin should generally be used alone, if a dmenu replacement is needed. This can be done with `anyrun --plugins libstdin.so`.
The content to fuzzy match on needs to be piped into Anyrun.
## Configuration
```ron
Config(
// Whether to allow the user to input any arbitrary text besides the options provided
allow_invalid: false,
// How many entries should be displayed at max
max_entries: 5,
)
```