Apply rustfmt pass across all modules
Pure whitespace normalization — no logic changes. Mostly: - collapsing multi-line match/if arms rustfmt prefers inline - inlining short `with_context`/`ok_or_else` closures - reformatting nested method chains for consistency Build and clippy stay clean. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+15
-39
@@ -104,8 +104,7 @@ fn regex_escape(s: &str) -> String {
|
|||||||
for c in s.chars() {
|
for c in s.chars() {
|
||||||
if matches!(
|
if matches!(
|
||||||
c,
|
c,
|
||||||
'.' | '*' | '?' | '+' | '(' | ')' | '[' | ']'
|
'.' | '*' | '?' | '+' | '(' | ')' | '[' | ']' | '{' | '}' | '|' | '\\' | '^' | '$'
|
||||||
| '{' | '}' | '|' | '\\' | '^' | '$'
|
|
||||||
) {
|
) {
|
||||||
out.push('\\');
|
out.push('\\');
|
||||||
}
|
}
|
||||||
@@ -237,9 +236,8 @@ impl Config {
|
|||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let bak = path.with_extension("toml.bak");
|
let bak = path.with_extension("toml.bak");
|
||||||
std::fs::rename(&path, &bak).with_context(|| {
|
std::fs::rename(&path, &bak)
|
||||||
format!("Failed to back up stale config to {bak:?}")
|
.with_context(|| format!("Failed to back up stale config to {bak:?}"))?;
|
||||||
})?;
|
|
||||||
eprintln!("warning: couldn't parse {}: {e}", path.display());
|
eprintln!("warning: couldn't parse {}: {e}", path.display());
|
||||||
eprintln!(
|
eprintln!(
|
||||||
" backed up to {} — writing fresh config with presets",
|
" backed up to {} — writing fresh config with presets",
|
||||||
@@ -305,8 +303,7 @@ impl Config {
|
|||||||
anyhow::bail!("launcher '{name}' already exists");
|
anyhow::bail!("launcher '{name}' already exists");
|
||||||
}
|
}
|
||||||
let display = display.unwrap_or_else(|| name.clone());
|
let display = display.unwrap_or_else(|| name.clone());
|
||||||
let prefix_dir = prefix_dir
|
let prefix_dir = prefix_dir.unwrap_or_else(|| home_dir().join("Games").join(&name));
|
||||||
.unwrap_or_else(|| home_dir().join("Games").join(&name));
|
|
||||||
let gameid = gameid.unwrap_or_else(|| format!("umu-{name}"));
|
let gameid = gameid.unwrap_or_else(|| format!("umu-{name}"));
|
||||||
let process_pattern = process_pattern.unwrap_or_else(|| {
|
let process_pattern = process_pattern.unwrap_or_else(|| {
|
||||||
exe_path
|
exe_path
|
||||||
@@ -346,13 +343,9 @@ impl Config {
|
|||||||
.launchers
|
.launchers
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|l| l.name == launcher)
|
.find(|l| l.name == launcher)
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| anyhow::anyhow!("no launcher named '{launcher}'"))?;
|
||||||
anyhow::anyhow!("no launcher named '{launcher}'")
|
|
||||||
})?;
|
|
||||||
if l.games.iter().any(|g| g.name == name) {
|
if l.games.iter().any(|g| g.name == name) {
|
||||||
anyhow::bail!(
|
anyhow::bail!("launcher '{launcher}' already has a game named '{name}'");
|
||||||
"launcher '{launcher}' already has a game named '{name}'"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
let display = display.unwrap_or_else(|| name.clone());
|
let display = display.unwrap_or_else(|| name.clone());
|
||||||
l.games.push(Game {
|
l.games.push(Game {
|
||||||
@@ -365,9 +358,7 @@ impl Config {
|
|||||||
gamescope,
|
gamescope,
|
||||||
});
|
});
|
||||||
self.save()?;
|
self.save()?;
|
||||||
println!(
|
println!("\x1b[1;32m✓\x1b[0m Added game '{name}' under launcher '{launcher}'.");
|
||||||
"\x1b[1;32m✓\x1b[0m Added game '{name}' under launcher '{launcher}'."
|
|
||||||
);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,15 +367,11 @@ impl Config {
|
|||||||
.launchers
|
.launchers
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|l| l.name == launcher)
|
.find(|l| l.name == launcher)
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| anyhow::anyhow!("no launcher named '{launcher}'"))?;
|
||||||
anyhow::anyhow!("no launcher named '{launcher}'")
|
|
||||||
})?;
|
|
||||||
let before = l.games.len();
|
let before = l.games.len();
|
||||||
l.games.retain(|g| g.name != name);
|
l.games.retain(|g| g.name != name);
|
||||||
if l.games.len() == before {
|
if l.games.len() == before {
|
||||||
anyhow::bail!(
|
anyhow::bail!("launcher '{launcher}' has no game named '{name}'");
|
||||||
"launcher '{launcher}' has no game named '{name}'"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
self.save()?;
|
self.save()?;
|
||||||
println!("\x1b[1;32m✓\x1b[0m Removed game '{name}' from '{launcher}'.");
|
println!("\x1b[1;32m✓\x1b[0m Removed game '{name}' from '{launcher}'.");
|
||||||
@@ -410,17 +397,10 @@ impl Config {
|
|||||||
.launchers
|
.launchers
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|l| l.name == launcher)
|
.find(|l| l.name == launcher)
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| anyhow::anyhow!("no launcher named '{launcher}'"))?;
|
||||||
anyhow::anyhow!("no launcher named '{launcher}'")
|
let g =
|
||||||
})?;
|
l.games.iter_mut().find(|g| g.name == name).ok_or_else(|| {
|
||||||
let g = l
|
anyhow::anyhow!("launcher '{launcher}' has no game named '{name}'")
|
||||||
.games
|
|
||||||
.iter_mut()
|
|
||||||
.find(|g| g.name == name)
|
|
||||||
.ok_or_else(|| {
|
|
||||||
anyhow::anyhow!(
|
|
||||||
"launcher '{launcher}' has no game named '{name}'"
|
|
||||||
)
|
|
||||||
})?;
|
})?;
|
||||||
if let Some(v) = gamemode {
|
if let Some(v) = gamemode {
|
||||||
g.gamemode = v;
|
g.gamemode = v;
|
||||||
@@ -432,9 +412,7 @@ impl Config {
|
|||||||
g.gamescope = v;
|
g.gamescope = v;
|
||||||
}
|
}
|
||||||
self.save()?;
|
self.save()?;
|
||||||
println!(
|
println!("\x1b[1;32m✓\x1b[0m Updated flags for '{launcher}/{name}'.");
|
||||||
"\x1b[1;32m✓\x1b[0m Updated flags for '{launcher}/{name}'."
|
|
||||||
);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -460,9 +438,7 @@ impl Config {
|
|||||||
compat_dir: Option<PathBuf>,
|
compat_dir: Option<PathBuf>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
if proton_version.is_none() && compat_dir.is_none() {
|
if proton_version.is_none() && compat_dir.is_none() {
|
||||||
anyhow::bail!(
|
anyhow::bail!("nothing to set — pass --proton-version or --compat-dir");
|
||||||
"nothing to set — pass --proton-version or --compat-dir"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if let Some(v) = proton_version {
|
if let Some(v) = proton_version {
|
||||||
self.proton_version = v;
|
self.proton_version = v;
|
||||||
|
|||||||
+3
-13
@@ -80,10 +80,7 @@ fn collect_prefixes(dir: &Path, depth: u32, out: &mut Vec<PathBuf>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_launchers(
|
fn match_launchers(config: &Config, prefixes: &[PathBuf]) -> HashMap<String, Vec<PathBuf>> {
|
||||||
config: &Config,
|
|
||||||
prefixes: &[PathBuf],
|
|
||||||
) -> HashMap<String, Vec<PathBuf>> {
|
|
||||||
let mut by_launcher: HashMap<String, Vec<PathBuf>> = HashMap::new();
|
let mut by_launcher: HashMap<String, Vec<PathBuf>> = HashMap::new();
|
||||||
for l in &config.launchers {
|
for l in &config.launchers {
|
||||||
for prefix in prefixes {
|
for prefix in prefixes {
|
||||||
@@ -114,11 +111,7 @@ fn print_findings(config: &Config, by_launcher: &HashMap<String, Vec<PathBuf>>)
|
|||||||
Some(matches) => {
|
Some(matches) => {
|
||||||
let detected = &matches[0];
|
let detected = &matches[0];
|
||||||
if *detected == l.prefix_dir {
|
if *detected == l.prefix_dir {
|
||||||
println!(
|
println!(" \x1b[1;32m✓\x1b[0m {:12} {}", l.name, detected.display());
|
||||||
" \x1b[1;32m✓\x1b[0m {:12} {}",
|
|
||||||
l.name,
|
|
||||||
detected.display()
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
any_divergent = true;
|
any_divergent = true;
|
||||||
println!(
|
println!(
|
||||||
@@ -136,10 +129,7 @@ fn print_findings(config: &Config, by_launcher: &HashMap<String, Vec<PathBuf>>)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_findings(
|
fn apply_findings(config: &Config, by_launcher: &HashMap<String, Vec<PathBuf>>) -> Result<()> {
|
||||||
config: &Config,
|
|
||||||
by_launcher: &HashMap<String, Vec<PathBuf>>,
|
|
||||||
) -> Result<()> {
|
|
||||||
let mut c = config.clone();
|
let mut c = config.clone();
|
||||||
let mut updated = 0;
|
let mut updated = 0;
|
||||||
let mut ambiguous = 0;
|
let mut ambiguous = 0;
|
||||||
|
|||||||
+17
-14
@@ -12,10 +12,18 @@ struct Check {
|
|||||||
|
|
||||||
impl Check {
|
impl Check {
|
||||||
fn pass(label: impl Into<String>, detail: impl Into<String>) -> Self {
|
fn pass(label: impl Into<String>, detail: impl Into<String>) -> Self {
|
||||||
Self { label: label.into(), pass: true, detail: detail.into() }
|
Self {
|
||||||
|
label: label.into(),
|
||||||
|
pass: true,
|
||||||
|
detail: detail.into(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn fail(label: impl Into<String>, detail: impl Into<String>) -> Self {
|
fn fail(label: impl Into<String>, detail: impl Into<String>) -> Self {
|
||||||
Self { label: label.into(), pass: false, detail: detail.into() }
|
Self {
|
||||||
|
label: label.into(),
|
||||||
|
pass: false,
|
||||||
|
detail: detail.into(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +89,10 @@ fn global_vulkan_check() -> Check {
|
|||||||
if ok {
|
if ok {
|
||||||
Check::pass("vulkan", "vulkaninfo OK")
|
Check::pass("vulkan", "vulkaninfo OK")
|
||||||
} else {
|
} else {
|
||||||
Check::fail("vulkan", "vulkaninfo failed — check GPU drivers / vulkan-tools")
|
Check::fail(
|
||||||
|
"vulkan",
|
||||||
|
"vulkaninfo failed — check GPU drivers / vulkan-tools",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,10 +141,7 @@ fn wineserver_check(config: &Config) -> Check {
|
|||||||
if count == 0 {
|
if count == 0 {
|
||||||
return Check::pass("wine procs", "no wineserver running");
|
return Check::pass("wine procs", "no wineserver running");
|
||||||
}
|
}
|
||||||
let any_running = config
|
let any_running = config.launchers.iter().any(crate::launcher::is_running);
|
||||||
.launchers
|
|
||||||
.iter()
|
|
||||||
.any(crate::launcher::is_running);
|
|
||||||
if any_running {
|
if any_running {
|
||||||
Check::pass(
|
Check::pass(
|
||||||
"wine procs",
|
"wine procs",
|
||||||
@@ -142,9 +150,7 @@ fn wineserver_check(config: &Config) -> Check {
|
|||||||
} else {
|
} else {
|
||||||
Check::fail(
|
Check::fail(
|
||||||
"wine procs",
|
"wine procs",
|
||||||
format!(
|
format!("{count} stale wineserver process(es) — try: umutray kill"),
|
||||||
"{count} stale wineserver process(es) — try: umutray kill"
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,10 +196,7 @@ fn launcher_checks(l: &Launcher) -> Vec<Check> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if is_owned_by_current_user(&l.prefix_dir) {
|
if is_owned_by_current_user(&l.prefix_dir) {
|
||||||
out.push(Check::pass(
|
out.push(Check::pass(format!("{tag} owner"), "owned by current user"));
|
||||||
format!("{tag} owner"),
|
|
||||||
"owned by current user",
|
|
||||||
));
|
|
||||||
} else {
|
} else {
|
||||||
out.push(Check::fail(
|
out.push(Check::fail(
|
||||||
format!("{tag} owner"),
|
format!("{tag} owner"),
|
||||||
|
|||||||
+24
-27
@@ -188,10 +188,7 @@ enum ConfigAction {
|
|||||||
gamescope: Option<String>,
|
gamescope: Option<String>,
|
||||||
},
|
},
|
||||||
/// Remove a game from a launcher
|
/// Remove a game from a launcher
|
||||||
RemoveGame {
|
RemoveGame { launcher: String, name: String },
|
||||||
launcher: String,
|
|
||||||
name: String,
|
|
||||||
},
|
|
||||||
/// Toggle per-game overlay flags
|
/// Toggle per-game overlay flags
|
||||||
SetGameFlags {
|
SetGameFlags {
|
||||||
launcher: String,
|
launcher: String,
|
||||||
@@ -267,7 +264,10 @@ fn main() -> Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Commands::Play { launcher: lname, game: gname } => {
|
Commands::Play {
|
||||||
|
launcher: lname,
|
||||||
|
game: gname,
|
||||||
|
} => {
|
||||||
let l = config.find(&lname).ok_or_else(|| {
|
let l = config.find(&lname).ok_or_else(|| {
|
||||||
anyhow::anyhow!("unknown launcher '{lname}' — try `umutray launchers`")
|
anyhow::anyhow!("unknown launcher '{lname}' — try `umutray launchers`")
|
||||||
})?;
|
})?;
|
||||||
@@ -294,7 +294,11 @@ fn main() -> Result<()> {
|
|||||||
println!(" {}:", l.display);
|
println!(" {}:", l.display);
|
||||||
for g in &l.games {
|
for g in &l.games {
|
||||||
let installed = g.full_exe_path(l).exists();
|
let installed = g.full_exe_path(l).exists();
|
||||||
let marker = if installed { "\x1b[1;32m✓\x1b[0m" } else { "·" };
|
let marker = if installed {
|
||||||
|
"\x1b[1;32m✓\x1b[0m"
|
||||||
|
} else {
|
||||||
|
"·"
|
||||||
|
};
|
||||||
let flags = format_game_flags(g);
|
let flags = format_game_flags(g);
|
||||||
println!(" {marker} {:14} {}{}", g.name, g.display, flags);
|
println!(" {marker} {:14} {}{}", g.name, g.display, flags);
|
||||||
}
|
}
|
||||||
@@ -312,7 +316,11 @@ fn main() -> Result<()> {
|
|||||||
detect::run(&config, &dir, apply)?;
|
detect::run(&config, &dir, apply)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Commands::UpdateProton { latest, version, list } => {
|
Commands::UpdateProton {
|
||||||
|
latest,
|
||||||
|
version,
|
||||||
|
list,
|
||||||
|
} => {
|
||||||
proton::run(&config, latest, version, list)?;
|
proton::run(&config, latest, version, list)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +330,10 @@ fn main() -> Result<()> {
|
|||||||
println!("{}", config::Config::config_path()?.display());
|
println!("{}", config::Config::config_path()?.display());
|
||||||
}
|
}
|
||||||
ConfigAction::Edit => config::Config::edit()?,
|
ConfigAction::Edit => config::Config::edit()?,
|
||||||
ConfigAction::Set { proton_version, compat_dir } => {
|
ConfigAction::Set {
|
||||||
|
proton_version,
|
||||||
|
compat_dir,
|
||||||
|
} => {
|
||||||
let mut c = config;
|
let mut c = config;
|
||||||
c.set_globals(proton_version, compat_dir)?;
|
c.set_globals(proton_version, compat_dir)?;
|
||||||
}
|
}
|
||||||
@@ -360,18 +371,9 @@ fn main() -> Result<()> {
|
|||||||
gamescope,
|
gamescope,
|
||||||
} => {
|
} => {
|
||||||
let mut c = config;
|
let mut c = config;
|
||||||
let gs = gamescope.map(|s| {
|
let gs =
|
||||||
s.split_whitespace().map(String::from).collect::<Vec<_>>()
|
gamescope.map(|s| s.split_whitespace().map(String::from).collect::<Vec<_>>());
|
||||||
});
|
c.add_game(&launcher, name, display, exe_path, gamemode, mangohud, gs)?;
|
||||||
c.add_game(
|
|
||||||
&launcher,
|
|
||||||
name,
|
|
||||||
display,
|
|
||||||
exe_path,
|
|
||||||
gamemode,
|
|
||||||
mangohud,
|
|
||||||
gs,
|
|
||||||
)?;
|
|
||||||
}
|
}
|
||||||
ConfigAction::RemoveGame { launcher, name } => {
|
ConfigAction::RemoveGame { launcher, name } => {
|
||||||
let mut c = config;
|
let mut c = config;
|
||||||
@@ -388,13 +390,8 @@ fn main() -> Result<()> {
|
|||||||
let gs_update = if no_gamescope {
|
let gs_update = if no_gamescope {
|
||||||
Some(None)
|
Some(None)
|
||||||
} else {
|
} else {
|
||||||
gamescope.map(|s| {
|
gamescope
|
||||||
Some(
|
.map(|s| Some(s.split_whitespace().map(String::from).collect::<Vec<_>>()))
|
||||||
s.split_whitespace()
|
|
||||||
.map(String::from)
|
|
||||||
.collect::<Vec<_>>(),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
let mut c = config;
|
let mut c = config;
|
||||||
c.set_game_flags(&launcher, &name, gamemode, mangohud, gs_update)?;
|
c.set_game_flags(&launcher, &name, gamemode, mangohud, gs_update)?;
|
||||||
|
|||||||
+18
-11
@@ -3,8 +3,7 @@ use anyhow::{Context, Result};
|
|||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
const GITHUB_API: &str =
|
const GITHUB_API: &str = "https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases";
|
||||||
"https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases";
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct Release {
|
struct Release {
|
||||||
@@ -153,7 +152,11 @@ fn print_list(config: &Config) -> Result<()> {
|
|||||||
let releases = fetch_releases(10)?;
|
let releases = fetch_releases(10)?;
|
||||||
for r in &releases {
|
for r in &releases {
|
||||||
let installed = config.proton_compat_dir.join(&r.tag_name).exists();
|
let installed = config.proton_compat_dir.join(&r.tag_name).exists();
|
||||||
let marker = if installed { " \x1b[1;32m✓ installed\x1b[0m" } else { "" };
|
let marker = if installed {
|
||||||
|
" \x1b[1;32m✓ installed\x1b[0m"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
};
|
||||||
println!(" {}{}", r.tag_name, marker);
|
println!(" {}{}", r.tag_name, marker);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -170,7 +173,12 @@ struct ProgressWriter<W: Write> {
|
|||||||
|
|
||||||
impl<W: Write> ProgressWriter<W> {
|
impl<W: Write> ProgressWriter<W> {
|
||||||
fn new(inner: W, total: Option<u64>) -> Self {
|
fn new(inner: W, total: Option<u64>) -> Self {
|
||||||
Self { inner, total, written: 0, last_print: 0 }
|
Self {
|
||||||
|
inner,
|
||||||
|
total,
|
||||||
|
written: 0,
|
||||||
|
last_print: 0,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn finish(&mut self) {
|
fn finish(&mut self) {
|
||||||
@@ -189,12 +197,7 @@ impl<W: Write> Write for ProgressWriter<W> {
|
|||||||
match self.total {
|
match self.total {
|
||||||
Some(t) => {
|
Some(t) => {
|
||||||
let pct = (self.written as f64 / t as f64) * 100.0;
|
let pct = (self.written as f64 / t as f64) * 100.0;
|
||||||
eprint!(
|
eprint!("\r {:.1}% ({} / {} MiB)", pct, self.written >> 20, t >> 20,);
|
||||||
"\r {:.1}% ({} / {} MiB)",
|
|
||||||
pct,
|
|
||||||
self.written >> 20,
|
|
||||||
t >> 20,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
None => eprint!("\r {} MiB", self.written >> 20),
|
None => eprint!("\r {} MiB", self.written >> 20),
|
||||||
}
|
}
|
||||||
@@ -217,7 +220,11 @@ fn pick_interactively(config: &Config) -> Result<String> {
|
|||||||
println!("Recent GE-Proton releases:");
|
println!("Recent GE-Proton releases:");
|
||||||
for (i, r) in releases.iter().enumerate() {
|
for (i, r) in releases.iter().enumerate() {
|
||||||
let installed = config.proton_compat_dir.join(&r.tag_name).exists();
|
let installed = config.proton_compat_dir.join(&r.tag_name).exists();
|
||||||
let marker = if installed { " \x1b[1;32m✓\x1b[0m" } else { "" };
|
let marker = if installed {
|
||||||
|
" \x1b[1;32m✓\x1b[0m"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
};
|
||||||
println!(" {:2}) {}{}", i + 1, r.tag_name, marker);
|
println!(" {:2}) {}{}", i + 1, r.tag_name, marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-6
@@ -43,13 +43,11 @@ fn systemctl(args: &[&str]) -> Result<()> {
|
|||||||
|
|
||||||
/// Write the unit, reload systemd, and enable+start the service.
|
/// Write the unit, reload systemd, and enable+start the service.
|
||||||
pub fn install() -> Result<()> {
|
pub fn install() -> Result<()> {
|
||||||
let exe = std::env::current_exe()
|
let exe = std::env::current_exe().context("Cannot determine path to own executable")?;
|
||||||
.context("Cannot determine path to own executable")?;
|
|
||||||
let path = unit_path()?;
|
let path = unit_path()?;
|
||||||
|
|
||||||
if let Some(parent) = path.parent() {
|
if let Some(parent) = path.parent() {
|
||||||
std::fs::create_dir_all(parent)
|
std::fs::create_dir_all(parent).with_context(|| format!("Failed to create {parent:?}"))?;
|
||||||
.with_context(|| format!("Failed to create {parent:?}"))?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let contents = render_unit(&exe);
|
let contents = render_unit(&exe);
|
||||||
@@ -77,8 +75,7 @@ pub fn uninstall() -> Result<()> {
|
|||||||
let _ = systemctl(&["disable", "--now", UNIT_NAME]);
|
let _ = systemctl(&["disable", "--now", UNIT_NAME]);
|
||||||
|
|
||||||
if path.exists() {
|
if path.exists() {
|
||||||
std::fs::remove_file(&path)
|
std::fs::remove_file(&path).with_context(|| format!("Failed to remove {path:?}"))?;
|
||||||
.with_context(|| format!("Failed to remove {path:?}"))?;
|
|
||||||
println!("Removed {}", path.display());
|
println!("Removed {}", path.display());
|
||||||
} else {
|
} else {
|
||||||
println!("No unit file at {}", path.display());
|
println!("No unit file at {}", path.display());
|
||||||
|
|||||||
+3
-9
@@ -119,8 +119,7 @@ fn update(state: &mut State, message: Message) -> Task<Message> {
|
|||||||
return Task::none();
|
return Task::none();
|
||||||
};
|
};
|
||||||
state.stage = Stage::Installing;
|
state.stage = Stage::Installing;
|
||||||
state.status =
|
state.status = "Running installer via umu-run (this may take several minutes)…".into();
|
||||||
"Running installer via umu-run (this may take several minutes)…".into();
|
|
||||||
if let Ok(mut v) = state.log.lock() {
|
if let Ok(mut v) = state.log.lock() {
|
||||||
v.clear();
|
v.clear();
|
||||||
}
|
}
|
||||||
@@ -165,11 +164,7 @@ fn subscription(state: &State) -> Subscription<Message> {
|
|||||||
|
|
||||||
fn view(state: &State) -> Element<'_, Message> {
|
fn view(state: &State) -> Element<'_, Message> {
|
||||||
let header = text(format!("Setup: {}", state.launcher.display)).size(24);
|
let header = text(format!("Setup: {}", state.launcher.display)).size(24);
|
||||||
let prefix = text(format!(
|
let prefix = text(format!("Prefix: {}", state.launcher.prefix_dir.display())).size(13);
|
||||||
"Prefix: {}",
|
|
||||||
state.launcher.prefix_dir.display()
|
|
||||||
))
|
|
||||||
.size(13);
|
|
||||||
let expected = text(format!(
|
let expected = text(format!(
|
||||||
"Expected: {}",
|
"Expected: {}",
|
||||||
state.launcher.full_exe_path().display()
|
state.launcher.full_exe_path().display()
|
||||||
@@ -180,8 +175,7 @@ fn view(state: &State) -> Element<'_, Message> {
|
|||||||
.on_input(Message::SourceChanged)
|
.on_input(Message::SourceChanged)
|
||||||
.padding(8);
|
.padding(8);
|
||||||
|
|
||||||
let prepare_enabled =
|
let prepare_enabled = matches!(state.stage, Stage::Idle | Stage::Ready | Stage::Finished);
|
||||||
matches!(state.stage, Stage::Idle | Stage::Ready | Stage::Finished);
|
|
||||||
let install_enabled = matches!(state.stage, Stage::Ready);
|
let install_enabled = matches!(state.stage, Stage::Ready);
|
||||||
|
|
||||||
let prepare_btn = button(text("Download / Prepare"))
|
let prepare_btn = button(text("Download / Prepare"))
|
||||||
|
|||||||
Reference in New Issue
Block a user