make terminal emulator configurable

This commit is contained in:
2023-09-09 06:30:19 -07:00
parent e46c3d2b4d
commit c98a065587
10 changed files with 107 additions and 24 deletions

View File

@ -25,7 +25,7 @@ tauri-build = { version = "1.0.4", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.2", features = ["dialog", "os-all", "system-tray"] }
tauri = { version = "1.2", features = ["dialog", "dialog-open", "os-all", "system-tray"] }
tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" }
sodiumoxide = "0.2.7"
tokio = { version = ">=1.19", features = ["full"] }

View File

@ -1,5 +1,4 @@
use std::net::Ipv4Addr;
use std::ffi::OsString;
use std::path::PathBuf;
use auto_launch::AutoLaunchBuilder;
@ -15,8 +14,9 @@ pub struct TermConfig {
pub name: String,
// we call it exec because it isn't always the actual path,
// in some cases it's just the name and relies on path-searching
pub exec: PathBuf,
pub args: Vec<OsString>,
// it's a string because it can come from the frontend as json
pub exec: String,
pub args: Vec<String>,
}
@ -134,18 +134,20 @@ fn default_listen_port() -> u16 {
fn default_term_config() -> TermConfig {
#[cfg(windows)]
{
if let Ok(path) = which::which("pwsh.exe") {
return TermConfig {
name: "pwsh.exe".into(),
exec: "conhost.exe".into(),
args: vec![path.into_os_string()]
};
let shell = if which::which("pwsh.exe").is_ok() {
"pwsh.exe".to_string()
}
return TermConfig {
name: "powershell.exe".into(),
exec: "conhost.exe".into(),
args: vec!["powershell.exe".into()]
else {
"powershell.exe".to_string()
};
let (exec, args) = if cfg!(debug_assertions) {
("conhost.exe".to_string(), vec![shell.clone()])
} else {
(shell.clone(), vec![])
};
TermConfig { name: shell, exec, args }
}
#[cfg(unix)]

View File

@ -12,7 +12,8 @@
},
"tauri": {
"allowlist": {
"os": {"all": true}
"os": {"all": true},
"dialog": {"open": true}
},
"bundle": {
"active": true,