Compare commits
39 Commits
7e5ed3d447
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 4845ebe4f8 | |||
| c1893f9f64 | |||
| 2f4f1c64d2 | |||
| 8447581fe6 | |||
| a0ee01cd5d | |||
| aeed52d6dd | |||
| 2b538a286a | |||
| e213377a95 | |||
| f3f5046265 | |||
| 4e204d4bf7 | |||
| d3ac300b91 | |||
| 3c1742174b | |||
| b81c7fd863 | |||
| a1afa59f1a | |||
| 32c6e1fce0 | |||
| 20509fb488 | |||
| f645b58470 | |||
| 9ad1e6a745 | |||
| f70498158a | |||
| 3c78e1586f | |||
| 0c22e23ad3 | |||
| 108f385973 | |||
| d97a13e289 | |||
| 2e51b2e788 | |||
| c4587b0729 | |||
| d4f0515a82 | |||
| 156bb460a0 | |||
| 9134d3bab0 | |||
| 74f21b6b75 | |||
| 05a12b7cee | |||
| f170171895 | |||
| 9b7e474e80 | |||
| f2f584febf | |||
| 4c918e673b | |||
| 1bacf345f0 | |||
| e72ee69c14 | |||
| b72c642223 | |||
| 22fa1efabf | |||
| 14eccf4ef0 |
@@ -1 +1,10 @@
|
|||||||
/target
|
/target
|
||||||
|
.vscode/
|
||||||
|
.claude/
|
||||||
|
CLAUDE.md
|
||||||
|
|
||||||
|
# Packaging build artifacts
|
||||||
|
packaging/pkg/
|
||||||
|
packaging/src/
|
||||||
|
packaging/umutray/
|
||||||
|
packaging/*.pkg.tar.zst
|
||||||
|
|||||||
Generated
+3590
-246
File diff suppressed because it is too large
Load Diff
+16
-5
@@ -19,7 +19,7 @@ clap = { version = "4", features = ["derive"] }
|
|||||||
|
|
||||||
# Config serialisation
|
# Config serialisation
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
toml = "0.8"
|
toml = "1"
|
||||||
|
|
||||||
# GitHub API responses
|
# GitHub API responses
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
@@ -27,11 +27,22 @@ serde_json = "1"
|
|||||||
# Error handling
|
# Error handling
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
|
|
||||||
# XDG config / data paths
|
# XDG config / data / home paths
|
||||||
directories = "5"
|
dirs = "6"
|
||||||
|
|
||||||
|
# Terminal colour output
|
||||||
|
owo-colors = "4"
|
||||||
|
|
||||||
# System tray via D-Bus StatusNotifierItem (KDE, GNOME+AppIndicator, Xfce, etc.)
|
# System tray via D-Bus StatusNotifierItem (KDE, GNOME+AppIndicator, Xfce, etc.)
|
||||||
ksni = "0.2"
|
ksni = { version = "0.3", features = ["blocking"] }
|
||||||
|
|
||||||
# HTTP for GE-Proton GitHub releases API
|
# HTTP for GE-Proton GitHub releases API
|
||||||
reqwest = { version = "0.12", features = ["blocking", "json"] }
|
reqwest = { version = "0.13", features = ["blocking", "json"] }
|
||||||
|
|
||||||
|
# GUI for the setup wizard
|
||||||
|
iced = { version = "0.14", features = ["tokio"] }
|
||||||
|
iced_fonts = { version = "0.3", features = ["bootstrap"] }
|
||||||
|
tokio = { version = "1.52.1", features = ["rt"] }
|
||||||
|
|
||||||
|
# Native file dialogs via XDG Desktop Portal
|
||||||
|
rfd = "0.17"
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
# umutray
|
# umutray
|
||||||
|
|
||||||
|
> **Note:** This project is entirely vibe-coded by [Claude](https://claude.com).
|
||||||
|
> Every line of Rust, every commit message, and this README were written by
|
||||||
|
> an AI working from conversational prompts. Expect the usual caveats.
|
||||||
|
|
||||||
A small system-tray daemon and CLI for running Windows game launchers on
|
A small system-tray daemon and CLI for running Windows game launchers on
|
||||||
Linux via [umu-launcher](https://github.com/Open-Wine-Components/umu-launcher)
|
Linux via [umu-launcher](https://github.com/Open-Wine-Components/umu-launcher)
|
||||||
and [GE-Proton](https://github.com/GloriousEggroll/proton-ge-custom).
|
and [GE-Proton](https://github.com/GloriousEggroll/proton-ge-custom).
|
||||||
@@ -24,10 +28,12 @@ Launch / Kill entries. Users can add or remove launchers in `config edit`.
|
|||||||
(no ~600 MB in-memory buffering), with a progress indicator.
|
(no ~600 MB in-memory buffering), with a progress indicator.
|
||||||
- `diagnose` — sanity-checks umu-run, Vulkan, display server, per-launcher
|
- `diagnose` — sanity-checks umu-run, Vulkan, display server, per-launcher
|
||||||
prefix / exe / ownership / running state.
|
prefix / exe / ownership / running state.
|
||||||
- `service` — installs a `systemd --user` unit so the tray autostarts with
|
- `autostart` — manages the XDG autostart entry so the tray starts with
|
||||||
the graphical session.
|
the graphical session.
|
||||||
- `setup` — prints the manual setup steps for a launcher (a graphical
|
- `setup` — graphical wizard (iced) that downloads an installer URL
|
||||||
wizard via iced is planned).
|
(with progress bar) or accepts a local `.exe`, then runs it via
|
||||||
|
`umu-run` in the launcher's Wine prefix with a live log pane.
|
||||||
|
Uninstalled launchers expose a **Setup…** entry directly in the tray.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
@@ -45,7 +51,7 @@ sudo pacman -S umu-launcher vulkan-tools
|
|||||||
Then enable autostart:
|
Then enable autostart:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
umutray service install
|
umutray autostart install
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
@@ -53,20 +59,29 @@ umutray service install
|
|||||||
| Command | What it does |
|
| Command | What it does |
|
||||||
| -------------------------------- | ------------------------------------------------------- |
|
| -------------------------------- | ------------------------------------------------------- |
|
||||||
| `umutray` | Start the tray daemon (default) |
|
| `umutray` | Start the tray daemon (default) |
|
||||||
|
| `umutray gui` | Open the graphical dashboard (with tray icon) |
|
||||||
| `umutray launchers` | List configured launchers and their state |
|
| `umutray launchers` | List configured launchers and their state |
|
||||||
| `umutray launch <name>` | Launch a specific launcher (e.g. `umutray launch epic`) |
|
| `umutray launch <name>` | Launch a specific launcher (e.g. `umutray launch epic`) |
|
||||||
| `umutray kill [<name>]` | Kill one launcher, or all if no name is given |
|
| `umutray kill [<name>]` | Kill one launcher, or all if no name is given |
|
||||||
|
| `umutray play <launcher> <game>` | Play a game with its configured overlays |
|
||||||
|
| `umutray games [<launcher>]` | List configured games and their overlay flags |
|
||||||
| `umutray diagnose [<name>]` | Health checks (one launcher or all) |
|
| `umutray diagnose [<name>]` | Health checks (one launcher or all) |
|
||||||
| `umutray setup <name>` | Print setup steps for a launcher |
|
| `umutray setup <name>` | Open the graphical setup wizard for a launcher |
|
||||||
|
| `umutray detect [--apply]` | Scan common Wine prefixes for installed launchers |
|
||||||
| `umutray update-proton --latest` | Install newest GE-Proton release |
|
| `umutray update-proton --latest` | Install newest GE-Proton release |
|
||||||
| `umutray update-proton --list` | Show recent releases without installing |
|
| `umutray update-proton --list` | Show recent releases without installing |
|
||||||
| `umutray update-proton` | Interactive version picker |
|
| `umutray update-proton` | Interactive version picker |
|
||||||
| `umutray config show` / `path` | Print current config or its file path |
|
| `umutray config show` / `path` | Print current config or its file path |
|
||||||
| `umutray config edit` | Open config in `$EDITOR` |
|
| `umutray config edit` | Open config in `$EDITOR` |
|
||||||
| `umutray config set …` | Update globals (`--proton-version`, `--compat-dir`) |
|
| `umutray config set …` | Update globals (`--proton-version`, `--compat-dir`) |
|
||||||
| `umutray service install` | Write + enable a `systemd --user` unit |
|
| `umutray config add-launcher …` | Append a new launcher (needs `--exe-path`) |
|
||||||
| `umutray service uninstall` | Stop, disable, and remove the unit |
|
| `umutray config remove-launcher` | Drop a launcher (prefix on disk is left untouched) |
|
||||||
| `umutray service status` | `systemctl --user status umutray.service` |
|
| `umutray config add-game …` | Attach a game to a launcher (needs `--exe-path`) |
|
||||||
|
| `umutray config remove-game …` | Drop a game from a launcher |
|
||||||
|
| `umutray config set-game-flags …`| Per-game overlay toggles: gamemode/mangohud/gamescope |
|
||||||
|
| `umutray autostart install` | Write XDG autostart entry (tray starts on login) |
|
||||||
|
| `umutray autostart uninstall` | Remove the autostart and desktop entries |
|
||||||
|
| `umutray autostart status` | Show whether XDG autostart is enabled |
|
||||||
|
|
||||||
## Config
|
## Config
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="256" height="256" viewBox="0 0 256 256"><path fill="#6A2DD0" transform="scale(0.25 0.25)" d="M316.83 489.317C317.107 484.743 317.387 484.045 319.792 480.106C331.825 460.403 344.692 441.083 357.09 421.576L426.676 310.088L460.178 256.008C465.12 247.892 470.692 238.565 475.589 230.368C485.332 214.061 494.15 201.062 515.652 207.922C526.275 211.312 534.508 228.056 540.153 237.267L561.887 272.304L651.315 415.661L675.648 454.536C681.1 463.353 686.925 473.61 693.188 481.796C693.471 484.01 693.683 486.232 693.823 488.46C694.069 495.055 694.774 499.229 691.701 505.13C687.363 508.231 685.162 509.801 679.583 507.794C672.444 505.226 666.114 500.865 659.488 497.208L606.838 468.035C598.995 463.67 590.498 457.656 582.318 454.761C579.585 463.73 577.836 472.577 575.242 481.379L533.513 622.349C529.194 636.653 518.538 676.017 511.284 687.126C506.749 689.685 504.339 689.506 499.435 688.833C498.47 688.213 497.545 687.533 496.665 686.797C494.438 684.872 492.749 682.401 491.764 679.627C487.819 668.528 484.428 654.073 481.349 642.721L460.784 565.328L441.896 494.692C439.173 484.508 432.807 464.261 431.753 453.965C422.177 456.49 412.453 463.896 403.931 468.831C397.648 472.47 391.092 475.633 384.73 479.133C375.143 484.408 335.982 507.269 328.008 508.414C323.524 509.058 320.824 506.354 317.583 503.743C316.948 499.784 316.946 493.481 316.83 489.317Z"/><path fill="#0DE3F9" transform="scale(0.25 0.25)" d="M316.83 489.317C326.713 487.058 361.145 466.68 372.023 460.761L411.657 439.075C419.599 434.76 435.454 426.313 442.416 421.007C445.878 429.66 449.515 445.075 451.785 454.299C455.003 467.441 458.333 480.554 461.774 493.639L488.319 592.414C493.49 612.086 498.3 634.105 503.702 653.315C507.136 645.111 510.74 630.302 513.341 621.249L530.525 561.547L563.101 448.881C565.546 440.194 569.012 430.374 571.228 421.862C590.026 431.246 682.27 488.827 693.823 488.46C694.069 495.055 694.774 499.229 691.701 505.13C687.363 508.231 685.162 509.801 679.583 507.794C672.444 505.226 666.114 500.865 659.488 497.208L606.838 468.035C598.995 463.67 590.498 457.656 582.318 454.761C579.585 463.73 577.836 472.577 575.242 481.379L533.513 622.349C529.194 636.653 518.538 676.017 511.284 687.126C506.749 689.685 504.339 689.506 499.435 688.833C498.47 688.213 497.545 687.533 496.665 686.797C494.438 684.872 492.749 682.401 491.764 679.627C487.819 668.528 484.428 654.073 481.349 642.721L460.784 565.328L441.896 494.692C439.173 484.508 432.807 464.261 431.753 453.965C422.177 456.49 412.453 463.896 403.931 468.831C397.648 472.47 391.092 475.633 384.73 479.133C375.143 484.408 335.982 507.269 328.008 508.414C323.524 509.058 320.824 506.354 317.583 503.743C316.948 499.784 316.946 493.481 316.83 489.317Z"/><path fill="#6A2DD0" transform="scale(0.25 0.25)" d="M587.904 557.75C594.63 558.35 636.107 580.289 645.251 584.753L707.547 615.372C722.827 622.791 739.073 629.822 753.378 639.13C758.309 642.764 762.436 647.947 765.177 653.232C775.79 673.694 769.385 696.993 750.511 709.963C742.787 715.271 735.331 718.229 726.892 722.364L691.26 739.957C670.813 749.813 648.337 761.827 628.013 772.246L565.409 803.747C552.588 810.117 539.24 817.98 525.599 821.676C501.993 828.073 478.772 820.911 458.344 808.937C455.519 807.534 452.539 805.546 449.614 804.348C437.518 799.393 426.435 793.024 414.839 787.176L345.748 752.392L296.932 728.286C278.678 719.455 255.575 711.06 246.053 692.148C241.346 682.798 240.626 669.13 243.911 659.221C249.793 641.473 265.715 634.257 281.362 626.711L363.987 585.171C378.809 577.73 404.312 564.178 419.551 558.967C420.161 563.911 423.45 572.363 425.066 577.529C429.662 592.226 435.14 605.968 439.405 620.812C433.705 622.439 418.179 630.443 412.013 633.482L361.205 658.483L339.266 668.935C335.952 670.529 334.485 669.629 334.151 673.003C333.569 672.051 415.662 713.259 423.407 717.013C442.821 726.191 462.067 735.718 481.137 745.59C487.422 748.819 500.053 754.835 505.208 759.089C507.704 759.259 514.834 754.663 517.462 753.24C524.303 749.591 531.199 746.044 538.147 742.6L637.624 692.709C650.159 686.478 665.981 677.686 678.576 672.23C664.077 663.98 648.275 657.584 633.456 649.828C621.72 643.686 609.236 637.96 597.176 632.47C587.431 628.034 575.228 620.477 564.906 618.184C566.354 611.945 570.995 601.874 573.401 595.696C578.278 583.174 583.569 570.468 587.904 557.75Z"/></svg>
|
||||||
|
After Width: | Height: | Size: 4.3 KiB |
@@ -0,0 +1,60 @@
|
|||||||
|
# Maintainer: funman300 <funman300@gmail.com>
|
||||||
|
#
|
||||||
|
# AUR NOTE: This PKGBUILD is kept in the source repo for convenience during
|
||||||
|
# development. For AUR submission, move it to a separate repository and update
|
||||||
|
# the `source` array to point to the upstream git URL instead of a local path.
|
||||||
|
#
|
||||||
|
# To build locally:
|
||||||
|
# cd packaging && makepkg -si
|
||||||
|
#
|
||||||
|
# To update for AUR, replace the source line with:
|
||||||
|
# source=("$pkgname::git+https://git.aleshym.co/funman300/umutray.git#tag=v$pkgver")
|
||||||
|
|
||||||
|
pkgname=umutray
|
||||||
|
pkgver=0.1.0
|
||||||
|
pkgrel=6
|
||||||
|
pkgdesc='Tray-based Wine launcher manager for Linux via umu/Proton-GE'
|
||||||
|
arch=('x86_64')
|
||||||
|
url='https://git.aleshym.co/funman300/umutray'
|
||||||
|
license=('MIT')
|
||||||
|
depends=('umu-launcher')
|
||||||
|
makedepends=('rust' 'cargo')
|
||||||
|
optdepends=(
|
||||||
|
'gamemode: per-game GameMode support'
|
||||||
|
'mangohud: per-game MangoHud overlay'
|
||||||
|
'gamescope: per-game Gamescope compositor'
|
||||||
|
)
|
||||||
|
|
||||||
|
# Build from the local repository. Change to the upstream URL for AUR.
|
||||||
|
_localrepo="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
source=("$pkgname::git+file://${_localrepo}")
|
||||||
|
sha256sums=('SKIP')
|
||||||
|
|
||||||
|
prepare() {
|
||||||
|
cd "$pkgname"
|
||||||
|
export RUSTUP_TOOLCHAIN=stable
|
||||||
|
cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
|
||||||
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
cd "$pkgname"
|
||||||
|
export RUSTUP_TOOLCHAIN=stable
|
||||||
|
export CARGO_TARGET_DIR=target
|
||||||
|
cargo build --release --locked --offline
|
||||||
|
}
|
||||||
|
|
||||||
|
package() {
|
||||||
|
cd "$pkgname"
|
||||||
|
|
||||||
|
# Binary
|
||||||
|
install -Dm755 target/release/umutray "$pkgdir/usr/bin/umutray"
|
||||||
|
|
||||||
|
# App menu entry
|
||||||
|
install -Dm644 umutray.desktop "$pkgdir/usr/share/applications/umutray.desktop"
|
||||||
|
|
||||||
|
# Icon
|
||||||
|
install -Dm644 assets/umutray.svg "$pkgdir/usr/share/icons/hicolor/scalable/apps/umutray.svg"
|
||||||
|
|
||||||
|
# License
|
||||||
|
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
|
||||||
|
}
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
use anyhow::{Context, Result};
|
||||||
|
use owo_colors::OwoColorize;
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
const DESKTOP_NAME: &str = "umutray.desktop";
|
||||||
|
const ICON_SVG: &[u8] = include_bytes!("../assets/umutray.svg");
|
||||||
|
|
||||||
|
fn home() -> Result<PathBuf> {
|
||||||
|
dirs::home_dir().context("Cannot determine home directory")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn autostart_path() -> Result<PathBuf> {
|
||||||
|
Ok(home()?.join(".config/autostart").join(DESKTOP_NAME))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn desktop_path() -> Result<PathBuf> {
|
||||||
|
Ok(home()?.join(".local/share/applications").join(DESKTOP_NAME))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn render_desktop(exe: &std::path::Path, autostart: bool) -> String {
|
||||||
|
let exec = if autostart {
|
||||||
|
format!("{}", exe.display())
|
||||||
|
} else {
|
||||||
|
format!("{} gui", exe.display())
|
||||||
|
};
|
||||||
|
let mut s = format!(
|
||||||
|
"[Desktop Entry]\n\
|
||||||
|
Name=umutray\n\
|
||||||
|
Comment=Wine launcher manager for Windows game launchers\n\
|
||||||
|
Exec={exec}\n\
|
||||||
|
Icon=umutray\n\
|
||||||
|
Type=Application\n\
|
||||||
|
Categories=Game;\n\
|
||||||
|
Keywords=wine;proton;gaming;launcher;\n\
|
||||||
|
StartupNotify=false\n",
|
||||||
|
);
|
||||||
|
if autostart {
|
||||||
|
s.push_str("X-GNOME-Autostart-enabled=true\n");
|
||||||
|
s.push_str("Hidden=false\n");
|
||||||
|
} else {
|
||||||
|
s.push_str("StartupNotify=true\n");
|
||||||
|
}
|
||||||
|
s
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ensure_parent(path: &Path) -> Result<()> {
|
||||||
|
if let Some(p) = path.parent() {
|
||||||
|
std::fs::create_dir_all(p)
|
||||||
|
.with_context(|| format!("Failed to create {}", p.display()))?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_file(path: &Path, contents: impl AsRef<[u8]>) -> Result<()> {
|
||||||
|
ensure_parent(path)?;
|
||||||
|
std::fs::write(path, contents)
|
||||||
|
.with_context(|| format!("Failed to write {}", path.display()))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn remove_file(path: &Path) -> Result<()> {
|
||||||
|
if path.exists() {
|
||||||
|
std::fs::remove_file(path)
|
||||||
|
.with_context(|| format!("Failed to remove {}", path.display()))?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn icon_path() -> Result<PathBuf> {
|
||||||
|
Ok(home()?.join(".local/share/icons/hicolor/scalable/apps/umutray.svg"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn install_icon() -> Result<()> {
|
||||||
|
write_file(&icon_path()?, ICON_SVG)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Ensure the tray icon SVG is present in the XDG icon theme directory.
|
||||||
|
/// Called automatically on startup so the icon works without needing
|
||||||
|
/// a separate install step.
|
||||||
|
pub fn ensure_icon() {
|
||||||
|
let Ok(path) = icon_path() else { return };
|
||||||
|
if !path.exists() {
|
||||||
|
let _ = install_icon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn uninstall_icon() -> Result<()> {
|
||||||
|
remove_file(&icon_path()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Install only the .desktop file so umutray appears in the app menu.
|
||||||
|
/// Called automatically on first `umutray gui` run.
|
||||||
|
pub fn install_desktop() -> Result<()> {
|
||||||
|
let exe = std::env::current_exe().context("Cannot determine path to own executable")?;
|
||||||
|
let desktop = desktop_path()?;
|
||||||
|
write_file(&desktop, render_desktop(&exe, false))?;
|
||||||
|
install_icon()?;
|
||||||
|
println!("{} App menu entry written: {}", "✓".green().bold(), desktop.display());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Remove the .desktop file.
|
||||||
|
pub fn uninstall_desktop() -> Result<()> {
|
||||||
|
let desktop = desktop_path()?;
|
||||||
|
if desktop.exists() {
|
||||||
|
remove_file(&desktop)?;
|
||||||
|
println!("Removed {}", desktop.display());
|
||||||
|
} else {
|
||||||
|
println!("No desktop file at {}", desktop.display());
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Write an XDG autostart entry and the app-menu .desktop file.
|
||||||
|
pub fn install() -> Result<()> {
|
||||||
|
let exe = std::env::current_exe().context("Cannot determine path to own executable")?;
|
||||||
|
|
||||||
|
// XDG autostart
|
||||||
|
let autostart = autostart_path()?;
|
||||||
|
write_file(&autostart, render_desktop(&exe, true))?;
|
||||||
|
println!("Wrote autostart: {}", autostart.display());
|
||||||
|
|
||||||
|
// App-menu entry
|
||||||
|
install_desktop()?;
|
||||||
|
|
||||||
|
println!();
|
||||||
|
println!("{} Autostart installed.", "✓".green().bold());
|
||||||
|
println!(" umutray will start with your next graphical session.");
|
||||||
|
println!(" To start now: {}", exe.display());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Remove the XDG autostart entry and the app-menu .desktop file.
|
||||||
|
pub fn uninstall() -> Result<()> {
|
||||||
|
let autostart = autostart_path()?;
|
||||||
|
if autostart.exists() {
|
||||||
|
remove_file(&autostart)?;
|
||||||
|
println!("Removed {}", autostart.display());
|
||||||
|
} else {
|
||||||
|
println!("No autostart file at {}", autostart.display());
|
||||||
|
}
|
||||||
|
|
||||||
|
uninstall_desktop()?;
|
||||||
|
uninstall_icon()?;
|
||||||
|
|
||||||
|
println!("{} Autostart removed.", "✓".green().bold());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Show whether the XDG autostart entry is present.
|
||||||
|
pub fn status() -> Result<()> {
|
||||||
|
let autostart = autostart_path()?;
|
||||||
|
if autostart.exists() {
|
||||||
|
println!("{} Autostart enabled: {}", "✓".green().bold(), autostart.display());
|
||||||
|
} else {
|
||||||
|
println!("{} Autostart not installed ({})", "✗".red().bold(), autostart.display());
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
+243
-28
@@ -1,8 +1,19 @@
|
|||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use directories::ProjectDirs;
|
use owo_colors::OwoColorize;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
/// Expresses the desired change to a game's gamescope setting.
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub enum GamescopeUpdate {
|
||||||
|
/// Leave the current value unchanged.
|
||||||
|
Unchanged,
|
||||||
|
/// Disable gamescope.
|
||||||
|
Disable,
|
||||||
|
/// Enable gamescope with the given CLI arguments.
|
||||||
|
Enable(Vec<String>),
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct Launcher {
|
pub struct Launcher {
|
||||||
/// Short CLI name (e.g. "battlenet").
|
/// Short CLI name (e.g. "battlenet").
|
||||||
@@ -24,6 +35,10 @@ pub struct Launcher {
|
|||||||
/// Config::proton_version).
|
/// Config::proton_version).
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
pub proton_version: Option<String>,
|
pub proton_version: Option<String>,
|
||||||
|
/// Games installed through this launcher. Overlays (gamemode, mangohud,
|
||||||
|
/// gamescope) only apply to games — the launcher itself always runs bare.
|
||||||
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
|
pub games: Vec<Game>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Launcher {
|
impl Launcher {
|
||||||
@@ -31,6 +46,40 @@ impl Launcher {
|
|||||||
pub fn full_exe_path(&self) -> PathBuf {
|
pub fn full_exe_path(&self) -> PathBuf {
|
||||||
self.prefix_dir.join("drive_c").join(&self.exe_path)
|
self.prefix_dir.join("drive_c").join(&self.exe_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn find_game(&self, name: &str) -> Option<&Game> {
|
||||||
|
self.games.iter().find(|g| g.name == name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct Game {
|
||||||
|
/// Short CLI name (e.g. "overwatch").
|
||||||
|
pub name: String,
|
||||||
|
/// Display name for tray / menus.
|
||||||
|
pub display: String,
|
||||||
|
/// Path to the game exe relative to the launcher's prefix `drive_c/`.
|
||||||
|
pub exe_path: PathBuf,
|
||||||
|
/// Optional extra args passed to the game exe after umu-run.
|
||||||
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
|
pub args: Vec<String>,
|
||||||
|
/// Wrap the game in `gamemoderun`.
|
||||||
|
#[serde(default)]
|
||||||
|
pub gamemode: bool,
|
||||||
|
/// Set `MANGOHUD=1` for the game process.
|
||||||
|
#[serde(default)]
|
||||||
|
pub mangohud: bool,
|
||||||
|
/// Wrap the game in `gamescope`. `None` = disabled; `Some(vec)` = enabled
|
||||||
|
/// with those CLI args (empty vec = gamescope defaults).
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub gamescope: Option<Vec<String>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Game {
|
||||||
|
/// Absolute path to the game exe inside the launcher's prefix.
|
||||||
|
pub fn full_exe_path(&self, launcher: &Launcher) -> PathBuf {
|
||||||
|
launcher.prefix_dir.join("drive_c").join(&self.exe_path)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
@@ -48,9 +97,7 @@ pub struct Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn home_dir() -> PathBuf {
|
fn home_dir() -> PathBuf {
|
||||||
std::env::var("HOME")
|
dirs::home_dir().expect("Cannot determine home directory")
|
||||||
.map(PathBuf::from)
|
|
||||||
.expect("$HOME is not set; cannot determine default paths")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_compat_dir() -> PathBuf {
|
fn default_compat_dir() -> PathBuf {
|
||||||
@@ -61,6 +108,20 @@ fn default_proton_version() -> String {
|
|||||||
"GE-Proton".into()
|
"GE-Proton".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn regex_escape(s: &str) -> String {
|
||||||
|
let mut out = String::with_capacity(s.len() + 4);
|
||||||
|
for c in s.chars() {
|
||||||
|
if matches!(
|
||||||
|
c,
|
||||||
|
'.' | '*' | '?' | '+' | '(' | ')' | '[' | ']' | '{' | '}' | '|' | '\\' | '^' | '$'
|
||||||
|
) {
|
||||||
|
out.push('\\');
|
||||||
|
}
|
||||||
|
out.push(c);
|
||||||
|
}
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|
||||||
/// The six launchers umutray ships out of the box. `exe_path`, `gameid`,
|
/// The six launchers umutray ships out of the box. `exe_path`, `gameid`,
|
||||||
/// and `process_pattern` are best-effort defaults for typical installs —
|
/// and `process_pattern` are best-effort defaults for typical installs —
|
||||||
/// users can adjust per-launcher via `umutray config edit`.
|
/// users can adjust per-launcher via `umutray config edit`.
|
||||||
@@ -75,9 +136,12 @@ pub fn presets() -> Vec<Launcher> {
|
|||||||
"Program Files (x86)/Battle.net/Battle.net Launcher.exe",
|
"Program Files (x86)/Battle.net/Battle.net Launcher.exe",
|
||||||
),
|
),
|
||||||
gameid: "umu-battlenet".into(),
|
gameid: "umu-battlenet".into(),
|
||||||
process_pattern: r"Battle\.net".into(),
|
process_pattern: r"Battle\.net|Blizzard.*Agent".into(),
|
||||||
installer_url: None,
|
installer_url: Some(
|
||||||
|
"https://www.battle.net/download/getInstallerForGame?os=win&gameProgram=BATTLENET_APP&version=Live".into(),
|
||||||
|
),
|
||||||
proton_version: None,
|
proton_version: None,
|
||||||
|
games: vec![],
|
||||||
},
|
},
|
||||||
Launcher {
|
Launcher {
|
||||||
name: "eaapp".into(),
|
name: "eaapp".into(),
|
||||||
@@ -88,8 +152,11 @@ pub fn presets() -> Vec<Launcher> {
|
|||||||
),
|
),
|
||||||
gameid: "umu-eaapp".into(),
|
gameid: "umu-eaapp".into(),
|
||||||
process_pattern: r"EADesktop\.exe".into(),
|
process_pattern: r"EADesktop\.exe".into(),
|
||||||
installer_url: None,
|
installer_url: Some(
|
||||||
|
"https://origin-a.akamaihd.net/EA-Desktop-Client-Download/installer-releases/EAappInstaller.exe".into(),
|
||||||
|
),
|
||||||
proton_version: None,
|
proton_version: None,
|
||||||
|
games: vec![],
|
||||||
},
|
},
|
||||||
Launcher {
|
Launcher {
|
||||||
name: "epic".into(),
|
name: "epic".into(),
|
||||||
@@ -100,8 +167,11 @@ pub fn presets() -> Vec<Launcher> {
|
|||||||
),
|
),
|
||||||
gameid: "umu-epicgameslauncher".into(),
|
gameid: "umu-epicgameslauncher".into(),
|
||||||
process_pattern: r"EpicGamesLauncher\.exe".into(),
|
process_pattern: r"EpicGamesLauncher\.exe".into(),
|
||||||
installer_url: None,
|
installer_url: Some(
|
||||||
|
"https://launcher-public-service-prod06.ol.epicgames.com/launcher/api/installer/download/EpicGamesLauncherInstaller.msi".into(),
|
||||||
|
),
|
||||||
proton_version: None,
|
proton_version: None,
|
||||||
|
games: vec![],
|
||||||
},
|
},
|
||||||
Launcher {
|
Launcher {
|
||||||
name: "ubisoft".into(),
|
name: "ubisoft".into(),
|
||||||
@@ -112,8 +182,11 @@ pub fn presets() -> Vec<Launcher> {
|
|||||||
),
|
),
|
||||||
gameid: "umu-uplay".into(),
|
gameid: "umu-uplay".into(),
|
||||||
process_pattern: r"UbisoftConnect\.exe|upc\.exe".into(),
|
process_pattern: r"UbisoftConnect\.exe|upc\.exe".into(),
|
||||||
installer_url: None,
|
installer_url: Some(
|
||||||
|
"https://ubistatic3-a.akamaihd.net/orbit/launcher_installer/UbisoftConnectInstaller.exe".into(),
|
||||||
|
),
|
||||||
proton_version: None,
|
proton_version: None,
|
||||||
|
games: vec![],
|
||||||
},
|
},
|
||||||
Launcher {
|
Launcher {
|
||||||
name: "gog".into(),
|
name: "gog".into(),
|
||||||
@@ -124,8 +197,11 @@ pub fn presets() -> Vec<Launcher> {
|
|||||||
),
|
),
|
||||||
gameid: "umu-gog".into(),
|
gameid: "umu-gog".into(),
|
||||||
process_pattern: r"GalaxyClient\.exe".into(),
|
process_pattern: r"GalaxyClient\.exe".into(),
|
||||||
installer_url: None,
|
installer_url: Some(
|
||||||
|
"https://webinstallers.gog-statics.com/download/GOG_Galaxy_2.0.exe".into(),
|
||||||
|
),
|
||||||
proton_version: None,
|
proton_version: None,
|
||||||
|
games: vec![],
|
||||||
},
|
},
|
||||||
Launcher {
|
Launcher {
|
||||||
name: "rockstar".into(),
|
name: "rockstar".into(),
|
||||||
@@ -136,8 +212,11 @@ pub fn presets() -> Vec<Launcher> {
|
|||||||
),
|
),
|
||||||
gameid: "umu-rockstar".into(),
|
gameid: "umu-rockstar".into(),
|
||||||
process_pattern: r"Rockstar Games.*Launcher\.exe".into(),
|
process_pattern: r"Rockstar Games.*Launcher\.exe".into(),
|
||||||
installer_url: None,
|
installer_url: Some(
|
||||||
|
"https://gamedownloads.rockstargames.com/public/installer/Rockstar-Games-Launcher.exe".into(),
|
||||||
|
),
|
||||||
proton_version: None,
|
proton_version: None,
|
||||||
|
games: vec![],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -147,16 +226,16 @@ impl Default for Config {
|
|||||||
Self {
|
Self {
|
||||||
proton_compat_dir: default_compat_dir(),
|
proton_compat_dir: default_compat_dir(),
|
||||||
proton_version: default_proton_version(),
|
proton_version: default_proton_version(),
|
||||||
launchers: presets(),
|
launchers: vec![],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
pub fn config_path() -> Result<PathBuf> {
|
pub fn config_path() -> Result<PathBuf> {
|
||||||
let dirs = ProjectDirs::from("co.aleshym", "", "umutray")
|
let config_dir = dirs::config_dir()
|
||||||
.context("Could not determine config directory")?;
|
.context("Could not determine config directory")?;
|
||||||
Ok(dirs.config_dir().join("config.toml"))
|
Ok(config_dir.join("umutray").join("config.toml"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load() -> Result<Self> {
|
pub fn load() -> Result<Self> {
|
||||||
@@ -167,20 +246,15 @@ impl Config {
|
|||||||
return Ok(c);
|
return Ok(c);
|
||||||
}
|
}
|
||||||
let content = std::fs::read_to_string(&path)
|
let content = std::fs::read_to_string(&path)
|
||||||
.with_context(|| format!("Failed to read config from {path:?}"))?;
|
.with_context(|| format!("Failed to read config from {}", path.display()))?;
|
||||||
match toml::from_str::<Self>(&content) {
|
match toml::from_str::<Self>(&content) {
|
||||||
Ok(mut c) => {
|
Ok(c) => {
|
||||||
if c.launchers.is_empty() {
|
|
||||||
c.launchers = presets();
|
|
||||||
c.save().context("Failed to write presets")?;
|
|
||||||
}
|
|
||||||
Ok(c)
|
Ok(c)
|
||||||
}
|
}
|
||||||
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.display()))?;
|
||||||
})?;
|
|
||||||
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",
|
||||||
@@ -200,7 +274,7 @@ impl Config {
|
|||||||
}
|
}
|
||||||
let content = toml::to_string_pretty(self)?;
|
let content = toml::to_string_pretty(self)?;
|
||||||
std::fs::write(&path, content)
|
std::fs::write(&path, content)
|
||||||
.with_context(|| format!("Failed to write config to {path:?}"))
|
.with_context(|| format!("Failed to write config to {}", path.display()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find(&self, name: &str) -> Option<&Launcher> {
|
pub fn find(&self, name: &str) -> Option<&Launcher> {
|
||||||
@@ -231,6 +305,149 @@ impl Config {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
pub fn add_launcher(
|
||||||
|
&mut self,
|
||||||
|
name: String,
|
||||||
|
display: Option<String>,
|
||||||
|
exe_path: PathBuf,
|
||||||
|
prefix_dir: Option<PathBuf>,
|
||||||
|
gameid: Option<String>,
|
||||||
|
process_pattern: Option<String>,
|
||||||
|
installer_url: Option<String>,
|
||||||
|
) -> Result<()> {
|
||||||
|
if self.launchers.iter().any(|l| l.name == name) {
|
||||||
|
anyhow::bail!("launcher '{name}' already exists");
|
||||||
|
}
|
||||||
|
let display = display.unwrap_or_else(|| name.clone());
|
||||||
|
let prefix_dir = prefix_dir.unwrap_or_else(|| home_dir().join("Games").join(&name));
|
||||||
|
let gameid = gameid.unwrap_or_else(|| format!("umu-{name}"));
|
||||||
|
let process_pattern = process_pattern.unwrap_or_else(|| {
|
||||||
|
exe_path
|
||||||
|
.file_name()
|
||||||
|
.and_then(|s| s.to_str())
|
||||||
|
.map(regex_escape)
|
||||||
|
.unwrap_or_else(|| name.clone())
|
||||||
|
});
|
||||||
|
self.launchers.push(Launcher {
|
||||||
|
name: name.clone(),
|
||||||
|
display,
|
||||||
|
prefix_dir,
|
||||||
|
exe_path,
|
||||||
|
gameid,
|
||||||
|
process_pattern,
|
||||||
|
installer_url,
|
||||||
|
proton_version: None,
|
||||||
|
games: vec![],
|
||||||
|
});
|
||||||
|
self.save()?;
|
||||||
|
println!("{} Added launcher '{name}'.", "✓".green().bold());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
pub fn add_game(
|
||||||
|
&mut self,
|
||||||
|
launcher: &str,
|
||||||
|
name: String,
|
||||||
|
display: Option<String>,
|
||||||
|
exe_path: PathBuf,
|
||||||
|
gamemode: bool,
|
||||||
|
mangohud: bool,
|
||||||
|
gamescope: Option<Vec<String>>,
|
||||||
|
) -> Result<()> {
|
||||||
|
let l = self
|
||||||
|
.launchers
|
||||||
|
.iter_mut()
|
||||||
|
.find(|l| l.name == launcher)
|
||||||
|
.ok_or_else(|| anyhow::anyhow!("no launcher named '{launcher}'"))?;
|
||||||
|
if l.games.iter().any(|g| g.name == name) {
|
||||||
|
anyhow::bail!("launcher '{launcher}' already has a game named '{name}'");
|
||||||
|
}
|
||||||
|
let display = display.unwrap_or_else(|| name.clone());
|
||||||
|
l.games.push(Game {
|
||||||
|
name: name.clone(),
|
||||||
|
display,
|
||||||
|
exe_path,
|
||||||
|
args: vec![],
|
||||||
|
gamemode,
|
||||||
|
mangohud,
|
||||||
|
gamescope,
|
||||||
|
});
|
||||||
|
self.save()?;
|
||||||
|
println!("{} Added game '{name}' under launcher '{launcher}'.", "✓".green().bold());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn remove_game(&mut self, launcher: &str, name: &str) -> Result<()> {
|
||||||
|
let l = self
|
||||||
|
.launchers
|
||||||
|
.iter_mut()
|
||||||
|
.find(|l| l.name == launcher)
|
||||||
|
.ok_or_else(|| anyhow::anyhow!("no launcher named '{launcher}'"))?;
|
||||||
|
let before = l.games.len();
|
||||||
|
l.games.retain(|g| g.name != name);
|
||||||
|
if l.games.len() == before {
|
||||||
|
anyhow::bail!("launcher '{launcher}' has no game named '{name}'");
|
||||||
|
}
|
||||||
|
self.save()?;
|
||||||
|
println!("{} Removed game '{name}' from '{launcher}'.", "✓".green().bold());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Update per-game overlay flags. Each arg is `None` = leave as-is.
|
||||||
|
pub fn set_game_flags(
|
||||||
|
&mut self,
|
||||||
|
launcher: &str,
|
||||||
|
name: &str,
|
||||||
|
gamemode: Option<bool>,
|
||||||
|
mangohud: Option<bool>,
|
||||||
|
gamescope: GamescopeUpdate,
|
||||||
|
) -> Result<()> {
|
||||||
|
if gamemode.is_none() && mangohud.is_none() && matches!(gamescope, GamescopeUpdate::Unchanged) {
|
||||||
|
anyhow::bail!(
|
||||||
|
"nothing to set — pass --gamemode, --mangohud, --gamescope, or --no-gamescope"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
let l = self
|
||||||
|
.launchers
|
||||||
|
.iter_mut()
|
||||||
|
.find(|l| l.name == launcher)
|
||||||
|
.ok_or_else(|| anyhow::anyhow!("no launcher named '{launcher}'"))?;
|
||||||
|
let g =
|
||||||
|
l.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 {
|
||||||
|
g.gamemode = v;
|
||||||
|
}
|
||||||
|
if let Some(v) = mangohud {
|
||||||
|
g.mangohud = v;
|
||||||
|
}
|
||||||
|
match gamescope {
|
||||||
|
GamescopeUpdate::Unchanged => {}
|
||||||
|
GamescopeUpdate::Disable => g.gamescope = None,
|
||||||
|
GamescopeUpdate::Enable(args) => g.gamescope = Some(args),
|
||||||
|
}
|
||||||
|
self.save()?;
|
||||||
|
println!("{} Updated flags for '{launcher}/{name}'.", "✓".green().bold());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn remove_launcher(&mut self, name: &str) -> Result<()> {
|
||||||
|
let before = self.launchers.len();
|
||||||
|
self.launchers.retain(|l| l.name != name);
|
||||||
|
if self.launchers.len() == before {
|
||||||
|
anyhow::bail!("no launcher named '{name}'");
|
||||||
|
}
|
||||||
|
self.save()?;
|
||||||
|
println!(
|
||||||
|
"{} Removed '{name}'. The Wine prefix on disk was left untouched.",
|
||||||
|
"✓".green().bold()
|
||||||
|
);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Update global fields non-interactively, then save.
|
/// Update global fields non-interactively, then save.
|
||||||
/// Use `config edit` for per-launcher changes.
|
/// Use `config edit` for per-launcher changes.
|
||||||
pub fn set_globals(
|
pub fn set_globals(
|
||||||
@@ -239,9 +456,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;
|
||||||
@@ -250,7 +465,7 @@ impl Config {
|
|||||||
self.proton_compat_dir = d;
|
self.proton_compat_dir = d;
|
||||||
}
|
}
|
||||||
self.save()?;
|
self.save()?;
|
||||||
println!("\x1b[1;32m✓\x1b[0m Config saved.");
|
println!("{} Config saved.", "✓".green().bold());
|
||||||
println!();
|
println!();
|
||||||
self.show()
|
self.show()
|
||||||
}
|
}
|
||||||
|
|||||||
+620
@@ -0,0 +1,620 @@
|
|||||||
|
use crate::config::{Config, Launcher};
|
||||||
|
use anyhow::Result;
|
||||||
|
use owo_colors::OwoColorize;
|
||||||
|
use std::collections::{HashMap, HashSet};
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
use std::sync::{LazyLock, Mutex};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct DetectHit {
|
||||||
|
pub display: String,
|
||||||
|
pub prefix: PathBuf,
|
||||||
|
/// True if this launcher is already in config with this exact prefix.
|
||||||
|
pub configured: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Scan default Wine prefix locations and return hits against known presets.
|
||||||
|
pub fn scan_for_gui(config: &Config) -> Vec<DetectHit> {
|
||||||
|
let roots: Vec<PathBuf> = default_roots().into_iter().filter(|r| r.is_dir()).collect();
|
||||||
|
let prefixes = scan_prefixes(&roots);
|
||||||
|
let mut hits = Vec::new();
|
||||||
|
for preset in crate::config::presets() {
|
||||||
|
for prefix in &prefixes {
|
||||||
|
if prefix.join("drive_c").join(&preset.exe_path).exists() {
|
||||||
|
let configured = config
|
||||||
|
.find(&preset.name)
|
||||||
|
.is_some_and(|l| l.prefix_dir == *prefix);
|
||||||
|
hits.push(DetectHit {
|
||||||
|
display: preset.display.clone(),
|
||||||
|
prefix: prefix.clone(),
|
||||||
|
configured,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hits
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Directories inside drive_c that contain Windows system files, not games.
|
||||||
|
const SYSTEM_DIRS: &[&str] = &[
|
||||||
|
"windows",
|
||||||
|
"users",
|
||||||
|
"programdata",
|
||||||
|
"internet explorer",
|
||||||
|
"windows media player",
|
||||||
|
"windowspowershell",
|
||||||
|
"microsoft.net",
|
||||||
|
"common files",
|
||||||
|
"microsoft",
|
||||||
|
"windows nt",
|
||||||
|
"windowsapps",
|
||||||
|
];
|
||||||
|
|
||||||
|
/// Directory names that are pure launcher infrastructure — no game executables
|
||||||
|
/// are ever installed here. Do NOT add parent dirs like "Epic Games" or
|
||||||
|
/// "Ubisoft" that also contain game subdirectories; use SKIP_EXES instead.
|
||||||
|
const SKIP_DIRS: &[&str] = &[
|
||||||
|
"battle.net", // Battle.net launcher dir; its games live elsewhere
|
||||||
|
"ea desktop", // EA Desktop launcher subfolder only
|
||||||
|
"gog galaxy", // GOG Galaxy launcher; games are normally in GOG Games/
|
||||||
|
"wine",
|
||||||
|
"mono",
|
||||||
|
"gecko",
|
||||||
|
];
|
||||||
|
|
||||||
|
/// Exe filename patterns that are launcher tools, not games.
|
||||||
|
const SKIP_EXES: &[&str] = &[
|
||||||
|
"uninstall",
|
||||||
|
"uninst",
|
||||||
|
"crash",
|
||||||
|
"error",
|
||||||
|
"reporter",
|
||||||
|
"update",
|
||||||
|
"updater",
|
||||||
|
"setup",
|
||||||
|
"installer",
|
||||||
|
"helper",
|
||||||
|
"agent",
|
||||||
|
"service",
|
||||||
|
"repair",
|
||||||
|
"diagnostic",
|
||||||
|
"redist",
|
||||||
|
"vcredist",
|
||||||
|
"dxsetup",
|
||||||
|
"dxwebsetup",
|
||||||
|
"dotnetfx",
|
||||||
|
"vc_redist",
|
||||||
|
"bootstrapper",
|
||||||
|
"launcher", // launcher tools, not games
|
||||||
|
"battlenet",
|
||||||
|
"blizzard",
|
||||||
|
"eadesktop",
|
||||||
|
"eabackgroundservice",
|
||||||
|
"ealink",
|
||||||
|
"epicgameslauncher",
|
||||||
|
"epicwebhelper",
|
||||||
|
"ubisoftconnect",
|
||||||
|
"ubisoftgamelauncher",
|
||||||
|
"upc",
|
||||||
|
"galaxyclient",
|
||||||
|
"galaxycommunication",
|
||||||
|
"galaxypeer",
|
||||||
|
"socialclubhelper",
|
||||||
|
"subprocess",
|
||||||
|
"cefprocess",
|
||||||
|
"webhelper",
|
||||||
|
"webview",
|
||||||
|
"7za",
|
||||||
|
"aria2c",
|
||||||
|
];
|
||||||
|
|
||||||
|
// --- Name resolution ---
|
||||||
|
|
||||||
|
/// Cache of absolute exe path → resolved display name (populated lazily).
|
||||||
|
static NAME_CACHE: LazyLock<Mutex<HashMap<PathBuf, String>>> =
|
||||||
|
LazyLock::new(|| Mutex::new(HashMap::new()));
|
||||||
|
|
||||||
|
/// Install-path → display title, built once from Legendary / Heroic metadata.
|
||||||
|
static STORE_TITLES: LazyLock<HashMap<PathBuf, String>> =
|
||||||
|
LazyLock::new(build_store_titles);
|
||||||
|
|
||||||
|
/// Read every `installed.json` that Legendary or Heroic may have written and
|
||||||
|
/// return a map of absolute install directory → game title.
|
||||||
|
fn build_store_titles() -> HashMap<PathBuf, String> {
|
||||||
|
let mut map = HashMap::new();
|
||||||
|
let Some(home) = dirs::home_dir() else { return map };
|
||||||
|
|
||||||
|
// Legendary standalone + Heroic's bundled copy (native and Flatpak).
|
||||||
|
let legendary_candidates = [
|
||||||
|
home.join(".config/legendary/installed.json"),
|
||||||
|
home.join(".config/heroic/legendaryConfig/legendary/installed.json"),
|
||||||
|
home.join(".var/app/com.heroicgameslauncher.hgl/config/legendary/installed.json"),
|
||||||
|
home.join(".var/app/com.heroicgameslauncher.hgl/config/heroic/legendaryConfig/legendary/installed.json"),
|
||||||
|
];
|
||||||
|
for path in &legendary_candidates {
|
||||||
|
if let Ok(text) = std::fs::read_to_string(path) {
|
||||||
|
parse_legendary_installed(&text, &mut map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Heroic GOG store (native and Flatpak).
|
||||||
|
let gog_candidates = [
|
||||||
|
home.join(".config/heroic/gog_store/installed.json"),
|
||||||
|
home.join(".var/app/com.heroicgameslauncher.hgl/config/heroic/gog_store/installed.json"),
|
||||||
|
];
|
||||||
|
for path in &gog_candidates {
|
||||||
|
if let Ok(text) = std::fs::read_to_string(path) {
|
||||||
|
parse_heroic_gog_installed(&text, &mut map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
map
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Legendary `installed.json`: `{ "AppName": { "install_path": "...", "title": "..." } }`
|
||||||
|
fn parse_legendary_installed(text: &str, map: &mut HashMap<PathBuf, String>) {
|
||||||
|
let Ok(json) = serde_json::from_str::<serde_json::Value>(text) else { return };
|
||||||
|
let Some(obj) = json.as_object() else { return };
|
||||||
|
for entry in obj.values() {
|
||||||
|
let Some(path) = entry.get("install_path").and_then(|v| v.as_str()) else { continue };
|
||||||
|
let Some(title) = entry.get("title").and_then(|v| v.as_str()) else { continue };
|
||||||
|
if !title.is_empty() {
|
||||||
|
map.insert(PathBuf::from(path), title.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Heroic GOG `installed.json`: `{ "installed": [ { "install_path": "...", "title": "..." } ] }`
|
||||||
|
fn parse_heroic_gog_installed(text: &str, map: &mut HashMap<PathBuf, String>) {
|
||||||
|
let Ok(json) = serde_json::from_str::<serde_json::Value>(text) else { return };
|
||||||
|
let Some(arr) = json.get("installed").and_then(|v| v.as_array()) else { return };
|
||||||
|
for entry in arr {
|
||||||
|
let Some(path) = entry.get("install_path").and_then(|v| v.as_str()) else { continue };
|
||||||
|
let Some(title) = entry.get("title").and_then(|v| v.as_str()) else { continue };
|
||||||
|
if !title.is_empty() {
|
||||||
|
map.insert(PathBuf::from(path), title.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Walk up from `exe_path` checking each ancestor against `STORE_TITLES`.
|
||||||
|
fn store_title(exe_path: &Path) -> Option<String> {
|
||||||
|
exe_path.ancestors().skip(1).find_map(|d| STORE_TITLES.get(d).cloned())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Scan a launcher's Wine prefix for installed game executables.
|
||||||
|
/// Returns (display_name, path_relative_to_drive_c) pairs, sorted alphabetically,
|
||||||
|
/// excluding the launcher's own exe and any already-configured games.
|
||||||
|
pub fn scan_games_in_prefix(launcher: &Launcher) -> Vec<(String, String)> {
|
||||||
|
let drive_c = launcher.prefix_dir.join("drive_c");
|
||||||
|
if !drive_c.exists() {
|
||||||
|
return vec![];
|
||||||
|
}
|
||||||
|
let search_dirs = [
|
||||||
|
drive_c.join("Program Files"),
|
||||||
|
drive_c.join("Program Files (x86)"),
|
||||||
|
];
|
||||||
|
let already: HashSet<String> = launcher
|
||||||
|
.games
|
||||||
|
.iter()
|
||||||
|
.map(|g| g.exe_path.to_string_lossy().to_lowercase())
|
||||||
|
.collect();
|
||||||
|
let launcher_exe = launcher.exe_path.to_string_lossy().to_lowercase();
|
||||||
|
|
||||||
|
let mut results = Vec::new();
|
||||||
|
let mut seen: HashSet<String> = HashSet::new();
|
||||||
|
for dir in &search_dirs {
|
||||||
|
scan_exe_dir(dir, &drive_c, &launcher_exe, &already, &mut results, &mut seen, 0);
|
||||||
|
}
|
||||||
|
results.sort_by(|a, b| a.0.cmp(&b.0));
|
||||||
|
results
|
||||||
|
}
|
||||||
|
|
||||||
|
fn scan_exe_dir(
|
||||||
|
dir: &Path,
|
||||||
|
drive_c: &Path,
|
||||||
|
launcher_exe: &str,
|
||||||
|
already: &HashSet<String>,
|
||||||
|
out: &mut Vec<(String, String)>,
|
||||||
|
seen: &mut HashSet<String>,
|
||||||
|
depth: u32,
|
||||||
|
) {
|
||||||
|
if depth > 4 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let Ok(entries) = std::fs::read_dir(dir) else { return };
|
||||||
|
for entry in entries.flatten() {
|
||||||
|
let path = entry.path();
|
||||||
|
let lower = path
|
||||||
|
.file_name()
|
||||||
|
.and_then(|n| n.to_str())
|
||||||
|
.unwrap_or("")
|
||||||
|
.to_lowercase();
|
||||||
|
if SYSTEM_DIRS.iter().any(|s| lower.starts_with(s)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if SKIP_DIRS.iter().any(|s| lower == *s) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if path.is_dir() {
|
||||||
|
scan_exe_dir(&path, drive_c, launcher_exe, already, out, seen, depth + 1);
|
||||||
|
} else if path
|
||||||
|
.extension()
|
||||||
|
.and_then(|e| e.to_str())
|
||||||
|
.is_some_and(|e| e.eq_ignore_ascii_case("exe"))
|
||||||
|
{
|
||||||
|
let Ok(rel) = path.strip_prefix(drive_c) else { continue };
|
||||||
|
let rel_str = rel.to_string_lossy().to_string();
|
||||||
|
let rel_lower = rel_str.to_lowercase();
|
||||||
|
if rel_lower == launcher_exe || already.contains(&rel_lower) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Skip launcher tools, updaters, and non-game executables
|
||||||
|
let stem_lower = path
|
||||||
|
.file_stem()
|
||||||
|
.and_then(|s| s.to_str())
|
||||||
|
.unwrap_or("")
|
||||||
|
.to_lowercase();
|
||||||
|
if SKIP_EXES.iter().any(|s| stem_lower.contains(s)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if !seen.insert(rel_lower) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let display = resolve_game_name(&path, None);
|
||||||
|
out.push((display, rel_str));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Resolve a human-readable display name for a game exe.
|
||||||
|
///
|
||||||
|
/// Resolution pipeline (first hit wins):
|
||||||
|
/// 1. Explicit name — if `explicit_name` is `Some`, return it immediately.
|
||||||
|
/// 2. Legendary / Heroic `installed.json` — maps install path → title,
|
||||||
|
/// covers both Epic (via Legendary) and GOG (via Heroic's GOG store).
|
||||||
|
/// 3. Manifest walk — walks up from the exe looking for GOG `.info` and
|
||||||
|
/// Epic `.egstore/*.item` JSON files at the game's installation root.
|
||||||
|
/// 4. Launcher path — reads the game name from well-known directory
|
||||||
|
/// structures laid down by the launcher (e.g. `Epic Games/<Name>/`).
|
||||||
|
/// 5. Nearest non-generic parent directory name, or raw exe stem.
|
||||||
|
/// No name generation — if the directory name is unknown, it is used
|
||||||
|
/// as-is rather than being fabricated from the exe filename.
|
||||||
|
///
|
||||||
|
/// Results from stages 2–5 are cached by path after first computation.
|
||||||
|
pub fn resolve_game_name(exe_path: &Path, explicit_name: Option<&str>) -> String {
|
||||||
|
if let Some(name) = explicit_name {
|
||||||
|
return name.to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let cache = NAME_CACHE.lock().unwrap_or_else(|e| e.into_inner());
|
||||||
|
if let Some(cached) = cache.get(exe_path) {
|
||||||
|
return cached.clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let name = resolve_uncached(exe_path);
|
||||||
|
|
||||||
|
NAME_CACHE
|
||||||
|
.lock()
|
||||||
|
.unwrap_or_else(|e| e.into_inner())
|
||||||
|
.insert(exe_path.to_path_buf(), name.clone());
|
||||||
|
|
||||||
|
name
|
||||||
|
}
|
||||||
|
|
||||||
|
fn resolve_uncached(exe_path: &Path) -> String {
|
||||||
|
// Stage 2 – Legendary / Heroic installed.json (install path → title)
|
||||||
|
if let Some(name) = store_title(exe_path) {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stage 3 – manifest files at the game's installation root
|
||||||
|
if let Some(name) = read_manifest_name(exe_path) {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stage 4 – game name from known launcher directory structures
|
||||||
|
if let Some(name) = name_from_launcher_path(exe_path) {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stage 5 – nearest non-generic parent directory, or raw exe stem.
|
||||||
|
// No name generation: if we don't know, we say so honestly.
|
||||||
|
prettify_exe_name(exe_path)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Walk up from `exe_path` looking for platform manifest files that record the
|
||||||
|
/// game's display name. Manifests live at the game's installation *root*, which
|
||||||
|
/// can be several directories above the actual exe.
|
||||||
|
///
|
||||||
|
/// Supported formats:
|
||||||
|
/// - GOG: `goggame-<id>.info` → `{ "gameName": "..." }`
|
||||||
|
/// - Epic: `.egstore/<id>.item` → `{ "DisplayName": "..." }`
|
||||||
|
fn read_manifest_name(exe_path: &Path) -> Option<String> {
|
||||||
|
for d in exe_path.ancestors().skip(1) {
|
||||||
|
let dirname = d.file_name().and_then(|n| n.to_str()).unwrap_or("").to_lowercase();
|
||||||
|
// Stop once we reach drive_c root or the Program Files tier — manifests
|
||||||
|
// are never above the game's installation folder.
|
||||||
|
if dirname == "drive_c" || dirname.starts_with("program files") {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if let Some(name) = read_gog_manifest(d).or_else(|| read_epic_manifest(d)) {
|
||||||
|
return Some(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_gog_manifest(dir: &Path) -> Option<String> {
|
||||||
|
for entry in std::fs::read_dir(dir).ok()?.flatten() {
|
||||||
|
let fname = entry.file_name();
|
||||||
|
let fname = fname.to_string_lossy();
|
||||||
|
if fname.starts_with("goggame-") && fname.ends_with(".info") {
|
||||||
|
let text = std::fs::read_to_string(entry.path()).ok()?;
|
||||||
|
let json: serde_json::Value = serde_json::from_str(&text).ok()?;
|
||||||
|
let t = json.get("gameName")?.as_str()?.trim();
|
||||||
|
if !t.is_empty() {
|
||||||
|
return Some(t.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_epic_manifest(dir: &Path) -> Option<String> {
|
||||||
|
let egstore = dir.join(".egstore");
|
||||||
|
if !egstore.is_dir() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
for entry in std::fs::read_dir(&egstore).ok()?.flatten() {
|
||||||
|
if entry.path().extension().and_then(|e| e.to_str()) == Some("item") {
|
||||||
|
let text = std::fs::read_to_string(entry.path()).ok()?;
|
||||||
|
let json: serde_json::Value = serde_json::from_str(&text).ok()?;
|
||||||
|
let t = json.get("DisplayName")?.as_str()?.trim();
|
||||||
|
if !t.is_empty() {
|
||||||
|
return Some(t.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Extract a game name from well-known launcher directory conventions.
|
||||||
|
///
|
||||||
|
/// Launchers install each game into a named subdirectory of their own folder.
|
||||||
|
/// That subdirectory name *is* the display name:
|
||||||
|
/// - Epic: `…/Epic Games/<GameName>/…`
|
||||||
|
/// - GOG: `…/GOG Games/<GameName>/…`
|
||||||
|
/// - Steam: `…/steamapps/common/<GameName>/…`
|
||||||
|
/// - Rockstar:`…/Rockstar Games/<GameName>/…`
|
||||||
|
/// - EA: `…/EA Games/<GameName>/…`
|
||||||
|
/// - Ubisoft: `…/Ubisoft Game Launcher/games/<GameName>/…`
|
||||||
|
fn name_from_launcher_path(exe_path: &Path) -> Option<String> {
|
||||||
|
let comps: Vec<&std::ffi::OsStr> = exe_path.components().map(|c| c.as_os_str()).collect();
|
||||||
|
|
||||||
|
for (i, comp) in comps.iter().enumerate() {
|
||||||
|
let lower = comp.to_str().unwrap_or("").to_lowercase();
|
||||||
|
match lower.as_str() {
|
||||||
|
"epic games" | "gog games" | "rockstar games" | "ea games" => {
|
||||||
|
return comps.get(i + 1).and_then(|c| c.to_str()).map(str::to_string);
|
||||||
|
}
|
||||||
|
// Ubisoft: …/Ubisoft Game Launcher/games/<GameName>/…
|
||||||
|
"ubisoft game launcher" => {
|
||||||
|
return comps.get(i + 2).and_then(|c| c.to_str()).map(str::to_string);
|
||||||
|
}
|
||||||
|
"common"
|
||||||
|
if i > 0
|
||||||
|
&& comps[i - 1].to_str().unwrap_or("").to_lowercase() == "steamapps" =>
|
||||||
|
{
|
||||||
|
return comps.get(i + 1).and_then(|c| c.to_str()).map(str::to_string);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Heuristic last-resort name derivation from an exe path.
|
||||||
|
///
|
||||||
|
/// Walks up parent directories looking for a non-generic name; falls back to
|
||||||
|
/// inserting spaces into the CamelCase / digit-boundary exe stem.
|
||||||
|
pub fn prettify_exe_name(path: &Path) -> String {
|
||||||
|
const GENERIC_DIRS: &[&str] = &[
|
||||||
|
"bin", "binaries", "x64", "x86", "win64", "win32", "retail",
|
||||||
|
"shipping", "game", "runtime", "_retail_", "_commonredist",
|
||||||
|
"launcher", "engine", "client",
|
||||||
|
];
|
||||||
|
|
||||||
|
for d in path.ancestors().skip(1) {
|
||||||
|
let name = d.file_name().and_then(|n| n.to_str()).unwrap_or("");
|
||||||
|
let lower = name.to_lowercase();
|
||||||
|
if !name.is_empty()
|
||||||
|
&& !GENERIC_DIRS.iter().any(|g| lower == *g)
|
||||||
|
&& !lower.starts_with("program files")
|
||||||
|
{
|
||||||
|
return name.to_string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nothing useful in the path — return the exe stem as-is.
|
||||||
|
path.file_stem()
|
||||||
|
.and_then(|s| s.to_str())
|
||||||
|
.unwrap_or("Unknown")
|
||||||
|
.to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
const MAX_DEPTH: u32 = 3;
|
||||||
|
|
||||||
|
pub fn run(config: &Config, extra_dirs: &[PathBuf], apply: bool) -> Result<()> {
|
||||||
|
let mut roots = default_roots();
|
||||||
|
roots.extend(extra_dirs.iter().cloned());
|
||||||
|
roots.sort();
|
||||||
|
roots.dedup();
|
||||||
|
let existing: Vec<PathBuf> = roots.into_iter().filter(|r| r.is_dir()).collect();
|
||||||
|
|
||||||
|
let prefixes = scan_prefixes(&existing);
|
||||||
|
println!(
|
||||||
|
"Scanned {} root{} → found {} prefix{}.\n",
|
||||||
|
existing.len(),
|
||||||
|
if existing.len() == 1 { "" } else { "s" },
|
||||||
|
prefixes.len(),
|
||||||
|
if prefixes.len() == 1 { "" } else { "es" },
|
||||||
|
);
|
||||||
|
|
||||||
|
let by_launcher = match_launchers(config, &prefixes);
|
||||||
|
|
||||||
|
if apply {
|
||||||
|
apply_findings(config, &by_launcher)?;
|
||||||
|
} else {
|
||||||
|
print_findings(config, &by_launcher);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_roots() -> Vec<PathBuf> {
|
||||||
|
let Some(home) = dirs::home_dir() else {
|
||||||
|
return Vec::new();
|
||||||
|
};
|
||||||
|
vec![
|
||||||
|
home.join("Games"),
|
||||||
|
home.join(".wine"),
|
||||||
|
home.join(".local/share/lutris/runners/wine"),
|
||||||
|
home.join(".local/share/bottles/bottles"),
|
||||||
|
home.join(".var/app/com.usebottles.bottles/data/bottles/bottles"),
|
||||||
|
home.join("Games/Heroic/Prefixes/default"),
|
||||||
|
home.join(".var/app/com.heroicgameslauncher.hgl/config/heroic/Prefixes/default"),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn scan_prefixes(roots: &[PathBuf]) -> Vec<PathBuf> {
|
||||||
|
let mut out = Vec::new();
|
||||||
|
for root in roots {
|
||||||
|
collect_prefixes(root, 0, &mut out);
|
||||||
|
}
|
||||||
|
out.sort();
|
||||||
|
out.dedup();
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|
||||||
|
fn collect_prefixes(dir: &Path, depth: u32, out: &mut Vec<PathBuf>) {
|
||||||
|
if dir.join("drive_c").is_dir() {
|
||||||
|
out.push(dir.to_path_buf());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Proton / umu layout: <gameid>/pfx/drive_c
|
||||||
|
if dir.join("pfx/drive_c").is_dir() {
|
||||||
|
out.push(dir.join("pfx"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if depth >= MAX_DEPTH {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let Ok(entries) = std::fs::read_dir(dir) else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
for entry in entries.flatten() {
|
||||||
|
if entry.file_type().is_ok_and(|t| t.is_dir()) {
|
||||||
|
collect_prefixes(&entry.path(), depth + 1, out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn match_launchers(config: &Config, prefixes: &[PathBuf]) -> HashMap<String, Vec<PathBuf>> {
|
||||||
|
let mut by_launcher: HashMap<String, Vec<PathBuf>> = HashMap::new();
|
||||||
|
for l in &config.launchers {
|
||||||
|
for prefix in prefixes {
|
||||||
|
if prefix.join("drive_c").join(&l.exe_path).exists() {
|
||||||
|
by_launcher
|
||||||
|
.entry(l.name.clone())
|
||||||
|
.or_default()
|
||||||
|
.push(prefix.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
by_launcher
|
||||||
|
}
|
||||||
|
|
||||||
|
fn print_findings(config: &Config, by_launcher: &HashMap<String, Vec<PathBuf>>) {
|
||||||
|
let mut any_divergent = false;
|
||||||
|
for l in &config.launchers {
|
||||||
|
match by_launcher.get(&l.name) {
|
||||||
|
None => {
|
||||||
|
println!(" · {:12} not found", l.name);
|
||||||
|
}
|
||||||
|
Some(matches) if matches.len() > 1 => {
|
||||||
|
println!(" {} {:12} multiple prefixes:", "⚠".yellow(), l.name);
|
||||||
|
for p in matches {
|
||||||
|
println!(" {}", p.display());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Some(matches) => {
|
||||||
|
let detected = &matches[0];
|
||||||
|
if *detected == l.prefix_dir {
|
||||||
|
println!(" {} {:12} {}", "✓".green().bold(), l.name, detected.display());
|
||||||
|
} else {
|
||||||
|
any_divergent = true;
|
||||||
|
println!(
|
||||||
|
" {} {:12} {} (was {})",
|
||||||
|
"→".cyan(),
|
||||||
|
l.name,
|
||||||
|
detected.display(),
|
||||||
|
l.prefix_dir.display()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if any_divergent {
|
||||||
|
println!("\nRerun with --apply to update config.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn apply_findings(config: &Config, by_launcher: &HashMap<String, Vec<PathBuf>>) -> Result<()> {
|
||||||
|
let mut c = config.clone();
|
||||||
|
let mut updated = 0;
|
||||||
|
let mut ambiguous = 0;
|
||||||
|
for l in c.launchers.iter_mut() {
|
||||||
|
let Some(matches) = by_launcher.get(&l.name) else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
if matches.len() > 1 {
|
||||||
|
ambiguous += 1;
|
||||||
|
println!(" {} {:12} ambiguous — update via `config edit`", "⚠".yellow(), l.name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let detected = &matches[0];
|
||||||
|
if *detected == l.prefix_dir {
|
||||||
|
println!(" {} {:12} unchanged", "✓".green().bold(), l.name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
println!(
|
||||||
|
" {} {:12} {} → {}",
|
||||||
|
"→".green().bold(),
|
||||||
|
l.name,
|
||||||
|
l.prefix_dir.display(),
|
||||||
|
detected.display()
|
||||||
|
);
|
||||||
|
l.prefix_dir = detected.clone();
|
||||||
|
updated += 1;
|
||||||
|
}
|
||||||
|
if updated > 0 {
|
||||||
|
c.save()?;
|
||||||
|
println!(
|
||||||
|
"\nUpdated {updated} launcher{}.",
|
||||||
|
if updated == 1 { "" } else { "s" }
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
println!("\nNothing to update.");
|
||||||
|
}
|
||||||
|
if ambiguous > 0 {
|
||||||
|
println!(
|
||||||
|
"{ambiguous} launcher{} skipped (multiple matches).",
|
||||||
|
if ambiguous == 1 { "" } else { "s" }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
+90
-56
@@ -1,16 +1,18 @@
|
|||||||
use crate::config::{Config, Launcher};
|
use crate::config::{Config, Launcher};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use owo_colors::OwoColorize;
|
||||||
use std::os::unix::fs::MetadataExt;
|
use std::os::unix::fs::MetadataExt;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
|
|
||||||
struct Check {
|
#[derive(Debug, Clone)]
|
||||||
label: String,
|
pub struct CheckResult {
|
||||||
pass: bool,
|
pub label: String,
|
||||||
detail: String,
|
pub pass: bool,
|
||||||
|
pub detail: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Check {
|
impl CheckResult {
|
||||||
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() }
|
||||||
}
|
}
|
||||||
@@ -19,14 +21,14 @@ impl Check {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run(config: &Config, name: Option<&str>) -> Result<()> {
|
pub fn run_checks(config: &Config, name: Option<&str>) -> Result<Vec<CheckResult>> {
|
||||||
let mut checks: Vec<Check> = vec![
|
let mut checks = vec![
|
||||||
global_umu_check(),
|
global_umu_check(),
|
||||||
global_vulkan_check(),
|
global_vulkan_check(),
|
||||||
global_display_check(),
|
global_display_check(),
|
||||||
compat_dir_check(config),
|
compat_dir_check(config),
|
||||||
|
wineserver_check(config),
|
||||||
];
|
];
|
||||||
|
|
||||||
let launchers: Vec<&Launcher> = if let Some(n) = name {
|
let launchers: Vec<&Launcher> = if let Some(n) = name {
|
||||||
let l = config
|
let l = config
|
||||||
.find(n)
|
.find(n)
|
||||||
@@ -38,70 +40,75 @@ pub fn run(config: &Config, name: Option<&str>) -> Result<()> {
|
|||||||
for l in launchers {
|
for l in launchers {
|
||||||
checks.extend(launcher_checks(l));
|
checks.extend(launcher_checks(l));
|
||||||
}
|
}
|
||||||
|
Ok(checks)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run(config: &Config, name: Option<&str>) -> Result<()> {
|
||||||
|
let checks = run_checks(config, name)?;
|
||||||
let mut issues = 0u32;
|
let mut issues = 0u32;
|
||||||
println!();
|
println!();
|
||||||
for c in &checks {
|
for c in &checks {
|
||||||
if !c.pass {
|
if !c.pass {
|
||||||
issues += 1;
|
issues += 1;
|
||||||
}
|
}
|
||||||
let (sym, col, rst) = if c.pass {
|
if c.pass {
|
||||||
("✓", "\x1b[1;32m", "\x1b[0m")
|
println!(" {} {:24} {}", "✓".green().bold(), c.label, c.detail);
|
||||||
} else {
|
} else {
|
||||||
("✗", "\x1b[1;31m", "\x1b[0m")
|
println!(" {} {:24} {}", "✗".red().bold(), c.label, c.detail);
|
||||||
};
|
}
|
||||||
println!(" {col}{sym}{rst} {:24} {}", c.label, c.detail);
|
|
||||||
}
|
}
|
||||||
println!();
|
println!();
|
||||||
if issues == 0 {
|
if issues == 0 {
|
||||||
println!(" \x1b[1;32mAll checks passed.\x1b[0m");
|
println!(" {}", "All checks passed.".green().bold());
|
||||||
} else {
|
} else {
|
||||||
println!(" \x1b[1;31m{issues} issue(s) found — see ✗ items above.\x1b[0m");
|
println!(" {}", format!("{issues} issue(s) found — see ✗ items above.").red().bold());
|
||||||
}
|
}
|
||||||
println!();
|
println!();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn global_umu_check() -> Check {
|
fn global_umu_check() -> CheckResult {
|
||||||
match which("umu-run") {
|
match which("umu-run") {
|
||||||
Some(p) => Check::pass("umu-run", format!("found at {p}")),
|
Some(p) => CheckResult::pass("umu-run", format!("found at {p}")),
|
||||||
None => Check::fail("umu-run", "not found — install umu-launcher"),
|
None => CheckResult::fail("umu-run", "not found — install umu-launcher"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn global_vulkan_check() -> Check {
|
fn global_vulkan_check() -> CheckResult {
|
||||||
let ok = Command::new("vulkaninfo")
|
let ok = Command::new("vulkaninfo")
|
||||||
.arg("--summary")
|
.arg("--summary")
|
||||||
.stdout(Stdio::null())
|
.stdout(Stdio::null())
|
||||||
.stderr(Stdio::null())
|
.stderr(Stdio::null())
|
||||||
.status()
|
.status()
|
||||||
.map(|s| s.success())
|
.is_ok_and(|s| s.success());
|
||||||
.unwrap_or(false);
|
|
||||||
if ok {
|
if ok {
|
||||||
Check::pass("vulkan", "vulkaninfo OK")
|
CheckResult::pass("vulkan", "vulkaninfo OK")
|
||||||
} else {
|
} else {
|
||||||
Check::fail("vulkan", "vulkaninfo failed — check GPU drivers / vulkan-tools")
|
CheckResult::fail(
|
||||||
|
"vulkan",
|
||||||
|
"vulkaninfo failed — check GPU drivers / vulkan-tools",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn global_display_check() -> Check {
|
fn global_display_check() -> CheckResult {
|
||||||
let display = std::env::var("DISPLAY").ok();
|
let display = std::env::var("DISPLAY").ok();
|
||||||
let wayland = std::env::var("WAYLAND_DISPLAY").ok();
|
let wayland = std::env::var("WAYLAND_DISPLAY").ok();
|
||||||
match (display, wayland) {
|
match (display, wayland) {
|
||||||
(Some(d), Some(_)) => Check::pass("display", format!("XWayland (DISPLAY={d})")),
|
(Some(d), Some(_)) => CheckResult::pass("display", format!("XWayland (DISPLAY={d})")),
|
||||||
(Some(d), None) => Check::pass("display", format!("X11 (DISPLAY={d})")),
|
(Some(d), None) => CheckResult::pass("display", format!("X11 (DISPLAY={d})")),
|
||||||
(None, Some(_)) => Check::fail(
|
(None, Some(_)) => CheckResult::fail(
|
||||||
"display",
|
"display",
|
||||||
"Wayland session but DISPLAY unset; XWayland needed",
|
"Wayland session but DISPLAY unset; XWayland needed",
|
||||||
),
|
),
|
||||||
(None, None) => Check::fail("display", "neither DISPLAY nor WAYLAND_DISPLAY set"),
|
(None, None) => CheckResult::fail("display", "neither DISPLAY nor WAYLAND_DISPLAY set"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compat_dir_check(config: &Config) -> Check {
|
fn compat_dir_check(config: &Config) -> CheckResult {
|
||||||
let n = count_ge_proton(&config.proton_compat_dir);
|
let n = count_ge_proton(&config.proton_compat_dir);
|
||||||
if config.proton_version == "GE-Proton" {
|
if config.proton_version == "GE-Proton" {
|
||||||
Check::pass(
|
CheckResult::pass(
|
||||||
"proton",
|
"proton",
|
||||||
format!(
|
format!(
|
||||||
"tracking latest; {n} version(s) in {}",
|
"tracking latest; {n} version(s) in {}",
|
||||||
@@ -111,9 +118,9 @@ fn compat_dir_check(config: &Config) -> Check {
|
|||||||
} else {
|
} else {
|
||||||
let path = config.proton_compat_dir.join(&config.proton_version);
|
let path = config.proton_compat_dir.join(&config.proton_version);
|
||||||
if path.exists() {
|
if path.exists() {
|
||||||
Check::pass("proton", format!("{} installed", config.proton_version))
|
CheckResult::pass("proton", format!("{} installed", config.proton_version))
|
||||||
} else {
|
} else {
|
||||||
Check::fail(
|
CheckResult::fail(
|
||||||
"proton",
|
"proton",
|
||||||
format!(
|
format!(
|
||||||
"{} missing — run: umutray update-proton --version={}",
|
"{} missing — run: umutray update-proton --version={}",
|
||||||
@@ -124,12 +131,41 @@ fn compat_dir_check(config: &Config) -> Check {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn launcher_checks(l: &Launcher) -> Vec<Check> {
|
fn wineserver_check(config: &Config) -> CheckResult {
|
||||||
|
let count = wineserver_count();
|
||||||
|
if count == 0 {
|
||||||
|
return CheckResult::pass("wine procs", "no wineserver running");
|
||||||
|
}
|
||||||
|
let any_running = config.launchers.iter().any(crate::launcher::is_running);
|
||||||
|
if any_running {
|
||||||
|
CheckResult::pass(
|
||||||
|
"wine procs",
|
||||||
|
format!("{count} wineserver process(es); launcher active"),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
CheckResult::fail(
|
||||||
|
"wine procs",
|
||||||
|
format!("{count} stale wineserver process(es) — try: umutray kill"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn wineserver_count() -> usize {
|
||||||
|
Command::new("pgrep")
|
||||||
|
.args(["-c", "-f", "wineserver"])
|
||||||
|
.output()
|
||||||
|
.ok()
|
||||||
|
.and_then(|o| String::from_utf8(o.stdout).ok())
|
||||||
|
.and_then(|s| s.trim().parse::<usize>().ok())
|
||||||
|
.unwrap_or(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn launcher_checks(l: &Launcher) -> Vec<CheckResult> {
|
||||||
let mut out = Vec::new();
|
let mut out = Vec::new();
|
||||||
let tag = format!("[{}]", l.name);
|
let tag = format!("[{}]", l.name);
|
||||||
|
|
||||||
if !l.prefix_dir.exists() {
|
if !l.prefix_dir.exists() {
|
||||||
out.push(Check::fail(
|
out.push(CheckResult::fail(
|
||||||
format!("{tag} prefix"),
|
format!("{tag} prefix"),
|
||||||
format!(
|
format!(
|
||||||
"{} missing — run: umutray setup {}",
|
"{} missing — run: umutray setup {}",
|
||||||
@@ -139,37 +175,34 @@ fn launcher_checks(l: &Launcher) -> Vec<Check> {
|
|||||||
));
|
));
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
out.push(Check::pass(
|
out.push(CheckResult::pass(
|
||||||
format!("{tag} prefix"),
|
format!("{tag} prefix"),
|
||||||
l.prefix_dir.display().to_string(),
|
l.prefix_dir.display().to_string(),
|
||||||
));
|
));
|
||||||
|
|
||||||
let exe = l.full_exe_path();
|
let exe = l.full_exe_path();
|
||||||
if exe.exists() {
|
if exe.exists() {
|
||||||
out.push(Check::pass(format!("{tag} exe"), "installed"));
|
out.push(CheckResult::pass(format!("{tag} exe"), "installed"));
|
||||||
} else {
|
} else {
|
||||||
out.push(Check::fail(
|
out.push(CheckResult::fail(
|
||||||
format!("{tag} exe"),
|
format!("{tag} exe"),
|
||||||
format!("missing — run: umutray setup {}", l.name),
|
format!("missing — run: umutray setup {}", l.name),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_owned_by_current_user(&l.prefix_dir) {
|
if is_owned_by_current_user(&l.prefix_dir) {
|
||||||
out.push(Check::pass(
|
out.push(CheckResult::pass(format!("{tag} owner"), "owned by current user"));
|
||||||
format!("{tag} owner"),
|
|
||||||
"owned by current user",
|
|
||||||
));
|
|
||||||
} else {
|
} else {
|
||||||
out.push(Check::fail(
|
out.push(CheckResult::fail(
|
||||||
format!("{tag} owner"),
|
format!("{tag} owner"),
|
||||||
"not owned by current user",
|
"not owned by current user",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if crate::launcher::is_running(l) {
|
if crate::launcher::is_running(l) {
|
||||||
out.push(Check::pass(format!("{tag} process"), "currently running"));
|
out.push(CheckResult::pass(format!("{tag} process"), "currently running"));
|
||||||
} else {
|
} else {
|
||||||
out.push(Check::pass(format!("{tag} process"), "not running"));
|
out.push(CheckResult::pass(format!("{tag} process"), "not running"));
|
||||||
}
|
}
|
||||||
|
|
||||||
out
|
out
|
||||||
@@ -184,8 +217,7 @@ fn count_ge_proton(dir: &Path) -> usize {
|
|||||||
.filter(|e| {
|
.filter(|e| {
|
||||||
e.file_name()
|
e.file_name()
|
||||||
.to_str()
|
.to_str()
|
||||||
.map(|s| s.starts_with("GE-Proton"))
|
.is_some_and(|s| s.starts_with("GE-Proton"))
|
||||||
.unwrap_or(false)
|
|
||||||
})
|
})
|
||||||
.count()
|
.count()
|
||||||
})
|
})
|
||||||
@@ -202,19 +234,21 @@ fn which(cmd: &str) -> Option<String> {
|
|||||||
.map(|s| s.trim().to_string())
|
.map(|s| s.trim().to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn current_uid() -> Option<u32> {
|
||||||
|
std::fs::read_to_string("/proc/self/status")
|
||||||
|
.ok()
|
||||||
|
.and_then(|s| {
|
||||||
|
s.lines()
|
||||||
|
.find(|l| l.starts_with("Uid:"))
|
||||||
|
.and_then(|l| l.split_whitespace().nth(1))
|
||||||
|
.and_then(|s| s.parse().ok())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fn is_owned_by_current_user(path: &Path) -> bool {
|
fn is_owned_by_current_user(path: &Path) -> bool {
|
||||||
let file_uid = match std::fs::metadata(path) {
|
let file_uid = match std::fs::metadata(path) {
|
||||||
Ok(m) => m.uid(),
|
Ok(m) => m.uid(),
|
||||||
Err(_) => return true,
|
Err(_) => return true,
|
||||||
};
|
};
|
||||||
let current_uid: Option<u32> = Command::new("id")
|
current_uid().map_or(true, |uid| uid == file_uid)
|
||||||
.arg("-u")
|
|
||||||
.output()
|
|
||||||
.ok()
|
|
||||||
.and_then(|o| String::from_utf8(o.stdout).ok())
|
|
||||||
.and_then(|s| s.trim().parse().ok());
|
|
||||||
match current_uid {
|
|
||||||
Some(uid) => uid == file_uid,
|
|
||||||
None => true,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1764
File diff suppressed because it is too large
Load Diff
+111
-23
@@ -1,38 +1,62 @@
|
|||||||
use crate::config::{Config, Launcher};
|
use crate::config::{Config, Game, Launcher};
|
||||||
use anyhow::{bail, Context, Result};
|
use anyhow::{bail, Context, Result};
|
||||||
|
use std::ffi::OsString;
|
||||||
|
use std::path::Path;
|
||||||
use std::process::Stdio;
|
use std::process::Stdio;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
/// Resolve PROTONPATH for umu-run: the literal "GE-Proton" makes umu-run
|
||||||
|
/// auto-fetch the latest; a pinned version gets the full path in compat_dir.
|
||||||
|
pub fn resolve_proton_path(config: &Config, launcher: &Launcher) -> OsString {
|
||||||
|
let version = launcher
|
||||||
|
.proton_version
|
||||||
|
.as_deref()
|
||||||
|
.unwrap_or(&config.proton_version);
|
||||||
|
if version == "GE-Proton" {
|
||||||
|
version.to_string().into()
|
||||||
|
} else {
|
||||||
|
config.proton_compat_dir.join(version).into_os_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Spawn the launcher via umu-run and return immediately.
|
/// Spawn the launcher via umu-run and return immediately.
|
||||||
pub fn launch(config: &Config, launcher: &Launcher) -> Result<()> {
|
pub fn launch(config: &Config, launcher: &Launcher) -> Result<()> {
|
||||||
let exe = launcher.full_exe_path();
|
let exe = launcher.full_exe_path();
|
||||||
if !exe.exists() {
|
if !exe.exists() {
|
||||||
bail!(
|
bail!(
|
||||||
"launcher exe not found at {:?}\n\
|
"launcher exe not found at {}\n\
|
||||||
Run `umutray setup {}` for setup instructions.",
|
Run `umutray setup {}` for setup instructions.",
|
||||||
exe,
|
exe.display(),
|
||||||
launcher.name,
|
launcher.name,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// PROTONPATH: umu-run accepts the literal "GE-Proton" to auto-fetch the
|
let proton_path = resolve_proton_path(config, launcher);
|
||||||
// latest; for any pinned version it expects a full path to the install dir.
|
|
||||||
let version = launcher
|
// Propagate overlay env vars from any configured game so that games
|
||||||
.proton_version
|
// launched from within the launcher (e.g. Battle.net → Diablo) inherit
|
||||||
.as_deref()
|
// them. gamemoderun wraps umu-run so the whole process tree gets
|
||||||
.unwrap_or(&config.proton_version);
|
// gamemode; MANGOHUD=1 is inherited by all child processes.
|
||||||
let proton_path: std::ffi::OsString = if version == "GE-Proton" {
|
let any_gamemode = launcher.games.iter().any(|g| g.gamemode);
|
||||||
version.to_string().into()
|
let any_mangohud = launcher.games.iter().any(|g| g.mangohud);
|
||||||
|
|
||||||
|
let (prog, args): (OsString, Vec<OsString>) = if any_gamemode {
|
||||||
|
let mut a = vec![OsString::from("umu-run")];
|
||||||
|
a.push(exe.into_os_string());
|
||||||
|
("gamemoderun".into(), a)
|
||||||
} else {
|
} else {
|
||||||
config.proton_compat_dir.join(version).into_os_string()
|
(OsString::from("umu-run"), vec![exe.into_os_string()])
|
||||||
};
|
};
|
||||||
|
|
||||||
std::process::Command::new("umu-run")
|
let mut cmd = std::process::Command::new(&prog);
|
||||||
.env("WINEPREFIX", &launcher.prefix_dir)
|
cmd.env("WINEPREFIX", &launcher.prefix_dir)
|
||||||
.env("GAMEID", &launcher.gameid)
|
.env("GAMEID", &launcher.gameid)
|
||||||
.env("PROTONPATH", &proton_path)
|
.env("PROTONPATH", &proton_path);
|
||||||
.arg(&exe)
|
if any_mangohud {
|
||||||
|
cmd.env("MANGOHUD", "1");
|
||||||
|
}
|
||||||
|
cmd.args(&args)
|
||||||
.spawn()
|
.spawn()
|
||||||
.context(
|
.context(
|
||||||
"Failed to spawn umu-run. Is it installed?\n\
|
"Failed to spawn umu-run. Is it installed?\n\
|
||||||
@@ -42,14 +66,80 @@ pub fn launch(config: &Config, launcher: &Launcher) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// SIGTERM → wait 3 s → SIGKILL for a single launcher.
|
/// Launch a game directly via umu-run, wrapped in the per-game overlays
|
||||||
pub fn kill(launcher: &Launcher) -> Result<()> {
|
/// (gamescope, gamemoderun, MANGOHUD). Ensures the parent launcher is
|
||||||
kill_pattern(&launcher.process_pattern);
|
/// running first so the game can authenticate online.
|
||||||
|
pub fn play_game(config: &Config, launcher: &Launcher, game: &Game) -> Result<()> {
|
||||||
|
let exe = game.full_exe_path(launcher);
|
||||||
|
if !exe.exists() {
|
||||||
|
bail!(
|
||||||
|
"game exe not found at {}\n\
|
||||||
|
Check exe_path for '{}/{}' in config, or install the game via the launcher first.",
|
||||||
|
exe.display(),
|
||||||
|
launcher.name,
|
||||||
|
game.name,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start the launcher if it isn't already running so the game has an
|
||||||
|
// active authentication session (avoids offline-mode).
|
||||||
|
if !is_running(launcher) {
|
||||||
|
launch(config, launcher)?;
|
||||||
|
// Give the launcher a moment to initialise before spawning the game.
|
||||||
|
thread::sleep(Duration::from_secs(5));
|
||||||
|
}
|
||||||
|
|
||||||
|
let proton_path = resolve_proton_path(config, launcher);
|
||||||
|
|
||||||
|
let (prog, args) = build_wrapped_argv(&exe, game);
|
||||||
|
|
||||||
|
let mut cmd = std::process::Command::new(&prog);
|
||||||
|
cmd.env("WINEPREFIX", &launcher.prefix_dir)
|
||||||
|
.env("GAMEID", &launcher.gameid)
|
||||||
|
.env("PROTONPATH", &proton_path);
|
||||||
|
if game.mangohud {
|
||||||
|
cmd.env("MANGOHUD", "1");
|
||||||
|
}
|
||||||
|
cmd.args(&args);
|
||||||
|
cmd.spawn().with_context(|| {
|
||||||
|
format!(
|
||||||
|
"Failed to spawn '{}'. Is umu-run / gamemoderun / gamescope on PATH?",
|
||||||
|
prog.to_string_lossy()
|
||||||
|
)
|
||||||
|
})?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Outermost → innermost: gamescope → gamemoderun → umu-run → exe [args]
|
||||||
|
fn build_wrapped_argv(exe: &Path, game: &Game) -> (OsString, Vec<OsString>) {
|
||||||
|
let mut argv: Vec<OsString> = Vec::new();
|
||||||
|
if let Some(gs_args) = &game.gamescope {
|
||||||
|
argv.push("gamescope".into());
|
||||||
|
for a in gs_args {
|
||||||
|
argv.push(a.into());
|
||||||
|
}
|
||||||
|
argv.push("--".into());
|
||||||
|
}
|
||||||
|
if game.gamemode {
|
||||||
|
argv.push("gamemoderun".into());
|
||||||
|
}
|
||||||
|
argv.push("umu-run".into());
|
||||||
|
argv.push(exe.as_os_str().to_os_string());
|
||||||
|
for a in &game.args {
|
||||||
|
argv.push(a.into());
|
||||||
|
}
|
||||||
|
let mut iter = argv.into_iter();
|
||||||
|
let prog = iter.next().expect("argv contains at least umu-run");
|
||||||
|
(prog, iter.collect())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// SIGTERM → wait 3 s → SIGKILL for a single launcher.
|
||||||
|
pub fn kill(launcher: &Launcher) {
|
||||||
|
kill_pattern(&launcher.process_pattern);
|
||||||
|
}
|
||||||
|
|
||||||
/// Kill every configured launcher's processes.
|
/// Kill every configured launcher's processes.
|
||||||
pub fn kill_all(config: &Config) -> Result<()> {
|
pub fn kill_all(config: &Config) {
|
||||||
// Single SIGTERM pass across all launchers, then one sleep, then SIGKILL.
|
// Single SIGTERM pass across all launchers, then one sleep, then SIGKILL.
|
||||||
// This keeps the total wait at 3 s instead of 3 s × N.
|
// This keeps the total wait at 3 s instead of 3 s × N.
|
||||||
for l in &config.launchers {
|
for l in &config.launchers {
|
||||||
@@ -59,7 +149,6 @@ pub fn kill_all(config: &Config) -> Result<()> {
|
|||||||
for l in &config.launchers {
|
for l in &config.launchers {
|
||||||
send_signal("-9", &l.process_pattern);
|
send_signal("-9", &l.process_pattern);
|
||||||
}
|
}
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn kill_pattern(pattern: &str) {
|
fn kill_pattern(pattern: &str) {
|
||||||
@@ -84,6 +173,5 @@ pub fn is_running(launcher: &Launcher) -> bool {
|
|||||||
.stdout(Stdio::null())
|
.stdout(Stdio::null())
|
||||||
.stderr(Stdio::null())
|
.stderr(Stdio::null())
|
||||||
.status()
|
.status()
|
||||||
.map(|s| s.success())
|
.is_ok_and(|s| s.success())
|
||||||
.unwrap_or(false)
|
|
||||||
}
|
}
|
||||||
|
|||||||
+304
-27
@@ -1,13 +1,20 @@
|
|||||||
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
|
mod detect;
|
||||||
mod diagnose;
|
mod diagnose;
|
||||||
|
mod gui;
|
||||||
mod launcher;
|
mod launcher;
|
||||||
mod proton;
|
mod proton;
|
||||||
mod service;
|
mod autostart;
|
||||||
mod setup;
|
mod setup;
|
||||||
|
mod theme;
|
||||||
mod tray;
|
mod tray;
|
||||||
|
mod util;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
use owo_colors::OwoColorize;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
/// Tray-based Wine launcher manager for Linux via umu/Proton-GE.
|
/// Tray-based Wine launcher manager for Linux via umu/Proton-GE.
|
||||||
@@ -46,10 +53,39 @@ enum Commands {
|
|||||||
/// List configured launchers and whether they're installed / running
|
/// List configured launchers and whether they're installed / running
|
||||||
Launchers,
|
Launchers,
|
||||||
|
|
||||||
/// Print setup instructions for a launcher (automated wizard coming soon)
|
/// Play a specific game through its launcher's prefix, applying the
|
||||||
|
/// per-game overlay flags (gamemode, mangohud, gamescope).
|
||||||
|
Play {
|
||||||
|
/// Launcher name (e.g. battlenet)
|
||||||
|
launcher: String,
|
||||||
|
/// Game name (e.g. overwatch)
|
||||||
|
game: String,
|
||||||
|
},
|
||||||
|
|
||||||
|
/// List configured games per launcher
|
||||||
|
Games {
|
||||||
|
/// Only show games for this launcher (omit for all)
|
||||||
|
launcher: Option<String>,
|
||||||
|
},
|
||||||
|
|
||||||
|
/// Open the graphical setup wizard. Omit NAME to pick from the launcher list.
|
||||||
Setup {
|
Setup {
|
||||||
/// Launcher name
|
/// Launcher name (e.g. battlenet). Omit to open the launcher picker.
|
||||||
name: String,
|
name: Option<String>,
|
||||||
|
},
|
||||||
|
|
||||||
|
/// Open the graphical dashboard (default when launched from app menu)
|
||||||
|
Gui,
|
||||||
|
|
||||||
|
/// Scan common Wine prefix locations for installed launchers
|
||||||
|
Detect {
|
||||||
|
/// Additional directory to scan (repeatable)
|
||||||
|
#[arg(long, value_name = "PATH")]
|
||||||
|
dir: Vec<PathBuf>,
|
||||||
|
|
||||||
|
/// Write detected prefix_dirs to config
|
||||||
|
#[arg(long)]
|
||||||
|
apply: bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Download and switch GE-Proton versions
|
/// Download and switch GE-Proton versions
|
||||||
@@ -73,10 +109,10 @@ enum Commands {
|
|||||||
action: ConfigAction,
|
action: ConfigAction,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Manage the systemd --user service that autostarts the tray
|
/// Manage the XDG autostart and desktop entries
|
||||||
Service {
|
Autostart {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
action: ServiceAction,
|
action: AutostartAction,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,22 +134,115 @@ enum ConfigAction {
|
|||||||
#[arg(long, value_name = "PATH")]
|
#[arg(long, value_name = "PATH")]
|
||||||
compat_dir: Option<PathBuf>,
|
compat_dir: Option<PathBuf>,
|
||||||
},
|
},
|
||||||
|
/// Add a new launcher to the config
|
||||||
|
AddLauncher {
|
||||||
|
/// Short CLI name (e.g. "heroic")
|
||||||
|
name: String,
|
||||||
|
|
||||||
|
/// Windows exe path relative to drive_c/ (e.g. "Program Files/Foo/foo.exe")
|
||||||
|
#[arg(long, value_name = "PATH")]
|
||||||
|
exe_path: PathBuf,
|
||||||
|
|
||||||
|
/// Display name for menus (defaults to NAME)
|
||||||
|
#[arg(long)]
|
||||||
|
display: Option<String>,
|
||||||
|
|
||||||
|
/// Wine prefix dir (defaults to ~/Games/NAME)
|
||||||
|
#[arg(long, value_name = "PATH")]
|
||||||
|
prefix_dir: Option<PathBuf>,
|
||||||
|
|
||||||
|
/// umu GAMEID (defaults to "umu-NAME")
|
||||||
|
#[arg(long)]
|
||||||
|
gameid: Option<String>,
|
||||||
|
|
||||||
|
/// pgrep -f regex (defaults to escaped exe basename)
|
||||||
|
#[arg(long)]
|
||||||
|
process_pattern: Option<String>,
|
||||||
|
|
||||||
|
/// Optional installer URL
|
||||||
|
#[arg(long)]
|
||||||
|
installer_url: Option<String>,
|
||||||
|
},
|
||||||
|
/// Remove a launcher from the config (leaves its prefix on disk)
|
||||||
|
RemoveLauncher {
|
||||||
|
/// Short CLI name
|
||||||
|
name: String,
|
||||||
|
},
|
||||||
|
/// Add a game under an existing launcher
|
||||||
|
AddGame {
|
||||||
|
/// Launcher that owns this game
|
||||||
|
launcher: String,
|
||||||
|
|
||||||
|
/// Short CLI name for the game (e.g. "overwatch")
|
||||||
|
name: String,
|
||||||
|
|
||||||
|
/// Game exe path relative to drive_c/
|
||||||
|
#[arg(long, value_name = "PATH")]
|
||||||
|
exe_path: PathBuf,
|
||||||
|
|
||||||
|
/// Display name (defaults to NAME)
|
||||||
|
#[arg(long)]
|
||||||
|
display: Option<String>,
|
||||||
|
|
||||||
|
/// Wrap the game in gamemoderun
|
||||||
|
#[arg(long)]
|
||||||
|
gamemode: bool,
|
||||||
|
|
||||||
|
/// Set MANGOHUD=1 for the game
|
||||||
|
#[arg(long)]
|
||||||
|
mangohud: bool,
|
||||||
|
|
||||||
|
/// Enable gamescope with these args (space-separated, e.g. "-f -W 2560")
|
||||||
|
#[arg(long, value_name = "ARGS")]
|
||||||
|
gamescope: Option<String>,
|
||||||
|
},
|
||||||
|
/// Remove a game from a launcher
|
||||||
|
RemoveGame { launcher: String, name: String },
|
||||||
|
/// Toggle per-game overlay flags
|
||||||
|
SetGameFlags {
|
||||||
|
launcher: String,
|
||||||
|
name: String,
|
||||||
|
|
||||||
|
/// true / false — wrap in gamemoderun
|
||||||
|
#[arg(long, value_name = "BOOL")]
|
||||||
|
gamemode: Option<bool>,
|
||||||
|
|
||||||
|
/// true / false — set MANGOHUD=1
|
||||||
|
#[arg(long, value_name = "BOOL")]
|
||||||
|
mangohud: Option<bool>,
|
||||||
|
|
||||||
|
/// Enable gamescope with these args (space-separated)
|
||||||
|
#[arg(long, value_name = "ARGS", conflicts_with = "no_gamescope")]
|
||||||
|
gamescope: Option<String>,
|
||||||
|
|
||||||
|
/// Disable gamescope wrapping
|
||||||
|
#[arg(long)]
|
||||||
|
no_gamescope: bool,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
enum ServiceAction {
|
enum AutostartAction {
|
||||||
/// Write the unit, daemon-reload, and enable+start the service
|
/// Write ~/.config/autostart/umutray.desktop so the tray starts on login (includes app menu entry)
|
||||||
Install,
|
Install,
|
||||||
/// Stop, disable, and remove the unit file
|
/// Remove the autostart entry and app menu entry
|
||||||
Uninstall,
|
Uninstall,
|
||||||
/// Show `systemctl --user status` for the service
|
/// Show whether the XDG autostart entry is present
|
||||||
Status,
|
Status,
|
||||||
|
/// Install only the app menu entry
|
||||||
|
InstallDesktop,
|
||||||
|
/// Remove the app menu entry
|
||||||
|
UninstallDesktop,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let cli = Cli::parse();
|
let cli = Cli::parse();
|
||||||
let config = config::Config::load()?;
|
let config = config::Config::load()?;
|
||||||
|
|
||||||
|
// Ensure the SVG icon is present in the XDG icon theme so the tray
|
||||||
|
// and desktop entries can find it without a separate install step.
|
||||||
|
autostart::ensure_icon();
|
||||||
|
|
||||||
match cli.command.unwrap_or(Commands::Tray) {
|
match cli.command.unwrap_or(Commands::Tray) {
|
||||||
Commands::Tray => tray::run(&config)?,
|
Commands::Tray => tray::run(&config)?,
|
||||||
|
|
||||||
@@ -129,9 +258,9 @@ fn main() -> Result<()> {
|
|||||||
let l = config.find(&n).ok_or_else(|| {
|
let l = config.find(&n).ok_or_else(|| {
|
||||||
anyhow::anyhow!("unknown launcher '{n}' — try `umutray launchers`")
|
anyhow::anyhow!("unknown launcher '{n}' — try `umutray launchers`")
|
||||||
})?;
|
})?;
|
||||||
launcher::kill(l)?;
|
launcher::kill(l);
|
||||||
}
|
}
|
||||||
None => launcher::kill_all(&config)?,
|
None => launcher::kill_all(&config),
|
||||||
},
|
},
|
||||||
|
|
||||||
Commands::Diagnose { name } => {
|
Commands::Diagnose { name } => {
|
||||||
@@ -142,24 +271,87 @@ fn main() -> Result<()> {
|
|||||||
for l in &config.launchers {
|
for l in &config.launchers {
|
||||||
let installed = l.full_exe_path().exists();
|
let installed = l.full_exe_path().exists();
|
||||||
let running = launcher::is_running(l);
|
let running = launcher::is_running(l);
|
||||||
let marker = if installed {
|
let marker = if installed { "✓".green().bold().to_string() } else { "·".to_string() };
|
||||||
"\x1b[1;32m✓\x1b[0m"
|
|
||||||
} else {
|
|
||||||
"·"
|
|
||||||
};
|
|
||||||
let state = if running { " (running)" } else { "" };
|
let state = if running { " (running)" } else { "" };
|
||||||
println!(" {marker} {:12} {}{}", l.name, l.display, state);
|
println!(" {marker} {:12} {}{}", l.name, l.display, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Commands::Setup { name } => {
|
Commands::Play {
|
||||||
let l = config.find(&name).ok_or_else(|| {
|
launcher: lname,
|
||||||
anyhow::anyhow!("unknown launcher '{name}' — try `umutray launchers`")
|
game: gname,
|
||||||
|
} => {
|
||||||
|
let l = config.find(&lname).ok_or_else(|| {
|
||||||
|
anyhow::anyhow!("unknown launcher '{lname}' — try `umutray launchers`")
|
||||||
|
})?;
|
||||||
|
let g = l.find_game(&gname).ok_or_else(|| {
|
||||||
|
anyhow::anyhow!(
|
||||||
|
"launcher '{lname}' has no game named '{gname}' — try `umutray games {lname}`"
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
launcher::play_game(&config, l, g)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Commands::Games { launcher: lname } => {
|
||||||
|
let launchers: Vec<&config::Launcher> = match &lname {
|
||||||
|
Some(n) => vec![config.find(n).ok_or_else(|| {
|
||||||
|
anyhow::anyhow!("unknown launcher '{n}' — try `umutray launchers`")
|
||||||
|
})?],
|
||||||
|
None => config.launchers.iter().collect(),
|
||||||
|
};
|
||||||
|
for l in launchers {
|
||||||
|
if l.games.is_empty() {
|
||||||
|
println!(" {}: (no games)", l.display);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
println!(" {}:", l.display);
|
||||||
|
for g in &l.games {
|
||||||
|
let installed = g.full_exe_path(l).exists();
|
||||||
|
let marker = if installed { "✓".green().bold().to_string() } else { "·".to_string() };
|
||||||
|
let flags = format_game_flags(g);
|
||||||
|
println!(" {marker} {:14} {}{}", g.name, g.display, flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Commands::Setup { name } => match name {
|
||||||
|
None => setup::run_new(&config)?,
|
||||||
|
Some(n) => {
|
||||||
|
let l = config.find(&n).ok_or_else(|| {
|
||||||
|
anyhow::anyhow!(
|
||||||
|
"unknown launcher '{n}' — try `umutray setup` to add it first"
|
||||||
|
)
|
||||||
})?;
|
})?;
|
||||||
setup::run(&config, l)?;
|
setup::run(&config, l)?;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
Commands::UpdateProton { latest, version, list } => {
|
Commands::Gui => {
|
||||||
|
// Start the tray icon immediately alongside the GUI.
|
||||||
|
let tray_handle = tray::spawn(&config);
|
||||||
|
|
||||||
|
match gui::run(&config)? {
|
||||||
|
gui::CloseAction::Quit => {
|
||||||
|
tray_handle.shutdown();
|
||||||
|
}
|
||||||
|
gui::CloseAction::MinimizeToTray => {
|
||||||
|
// GUI closed, tray keeps running. Block until killed.
|
||||||
|
loop {
|
||||||
|
std::thread::sleep(std::time::Duration::from_secs(60));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Commands::Detect { dir, apply } => {
|
||||||
|
detect::run(&config, &dir, apply)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Commands::UpdateProton {
|
||||||
|
latest,
|
||||||
|
version,
|
||||||
|
list,
|
||||||
|
} => {
|
||||||
proton::run(&config, latest, version, list)?;
|
proton::run(&config, latest, version, list)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,18 +361,103 @@ 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)?;
|
||||||
}
|
}
|
||||||
|
ConfigAction::AddLauncher {
|
||||||
|
name,
|
||||||
|
exe_path,
|
||||||
|
display,
|
||||||
|
prefix_dir,
|
||||||
|
gameid,
|
||||||
|
process_pattern,
|
||||||
|
installer_url,
|
||||||
|
} => {
|
||||||
|
let mut c = config;
|
||||||
|
c.add_launcher(
|
||||||
|
name,
|
||||||
|
display,
|
||||||
|
exe_path,
|
||||||
|
prefix_dir,
|
||||||
|
gameid,
|
||||||
|
process_pattern,
|
||||||
|
installer_url,
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
ConfigAction::RemoveLauncher { name } => {
|
||||||
|
let mut c = config;
|
||||||
|
c.remove_launcher(&name)?;
|
||||||
|
}
|
||||||
|
ConfigAction::AddGame {
|
||||||
|
launcher,
|
||||||
|
name,
|
||||||
|
exe_path,
|
||||||
|
display,
|
||||||
|
gamemode,
|
||||||
|
mangohud,
|
||||||
|
gamescope,
|
||||||
|
} => {
|
||||||
|
let mut c = config;
|
||||||
|
let gs =
|
||||||
|
gamescope.map(|s| s.split_whitespace().map(String::from).collect::<Vec<_>>());
|
||||||
|
c.add_game(&launcher, name, display, exe_path, gamemode, mangohud, gs)?;
|
||||||
|
}
|
||||||
|
ConfigAction::RemoveGame { launcher, name } => {
|
||||||
|
let mut c = config;
|
||||||
|
c.remove_game(&launcher, &name)?;
|
||||||
|
}
|
||||||
|
ConfigAction::SetGameFlags {
|
||||||
|
launcher,
|
||||||
|
name,
|
||||||
|
gamemode,
|
||||||
|
mangohud,
|
||||||
|
gamescope,
|
||||||
|
no_gamescope,
|
||||||
|
} => {
|
||||||
|
let gs_update = if no_gamescope {
|
||||||
|
config::GamescopeUpdate::Disable
|
||||||
|
} else if let Some(s) = gamescope {
|
||||||
|
config::GamescopeUpdate::Enable(
|
||||||
|
s.split_whitespace().map(String::from).collect(),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
config::GamescopeUpdate::Unchanged
|
||||||
|
};
|
||||||
|
let mut c = config;
|
||||||
|
c.set_game_flags(&launcher, &name, gamemode, mangohud, gs_update)?;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
Commands::Service { action } => match action {
|
Commands::Autostart { action } => match action {
|
||||||
ServiceAction::Install => service::install()?,
|
AutostartAction::Install => autostart::install()?,
|
||||||
ServiceAction::Uninstall => service::uninstall()?,
|
AutostartAction::Uninstall => autostart::uninstall()?,
|
||||||
ServiceAction::Status => service::status()?,
|
AutostartAction::Status => autostart::status()?,
|
||||||
|
AutostartAction::InstallDesktop => autostart::install_desktop()?,
|
||||||
|
AutostartAction::UninstallDesktop => autostart::uninstall_desktop()?,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn format_game_flags(g: &config::Game) -> String {
|
||||||
|
let mut tags: Vec<&str> = Vec::new();
|
||||||
|
if g.gamemode {
|
||||||
|
tags.push("gamemode");
|
||||||
|
}
|
||||||
|
if g.mangohud {
|
||||||
|
tags.push("mangohud");
|
||||||
|
}
|
||||||
|
if g.gamescope.is_some() {
|
||||||
|
tags.push("gamescope");
|
||||||
|
}
|
||||||
|
if tags.is_empty() {
|
||||||
|
String::new()
|
||||||
|
} else {
|
||||||
|
format!(" [{}]", tags.join(", "))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+64
-14
@@ -1,10 +1,12 @@
|
|||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
|
use owo_colors::OwoColorize;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use std::collections::HashSet;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
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 {
|
||||||
@@ -55,7 +57,7 @@ fn fetch_release(tag: &str) -> Result<Release> {
|
|||||||
fn install_version(config: &Config, tag: &str) -> Result<()> {
|
fn install_version(config: &Config, tag: &str) -> Result<()> {
|
||||||
let install_path = config.proton_compat_dir.join(tag);
|
let install_path = config.proton_compat_dir.join(tag);
|
||||||
if install_path.exists() {
|
if install_path.exists() {
|
||||||
println!("{tag} is already installed at {install_path:?}");
|
println!("{tag} is already installed at {}", install_path.display());
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,13 +83,13 @@ fn install_version(config: &Config, tag: &str) -> Result<()> {
|
|||||||
.context("Download returned an error status")?;
|
.context("Download returned an error status")?;
|
||||||
let total = resp.content_length();
|
let total = resp.content_length();
|
||||||
let f = std::fs::File::create(&tmp_path)
|
let f = std::fs::File::create(&tmp_path)
|
||||||
.with_context(|| format!("Failed to create temp file {tmp_path:?}"))?;
|
.with_context(|| format!("Failed to create temp file {}", tmp_path.display()))?;
|
||||||
let mut progress = ProgressWriter::new(f, total);
|
let mut progress = ProgressWriter::new(f, total);
|
||||||
std::io::copy(&mut resp, &mut progress).context("Failed to stream archive to disk")?;
|
std::io::copy(&mut resp, &mut progress).context("Failed to stream archive to disk")?;
|
||||||
progress.finish();
|
progress.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Extracting to {:?}...", config.proton_compat_dir);
|
println!("Extracting to {}...", config.proton_compat_dir.display());
|
||||||
std::fs::create_dir_all(&config.proton_compat_dir)?;
|
std::fs::create_dir_all(&config.proton_compat_dir)?;
|
||||||
|
|
||||||
let status = std::process::Command::new("tar")
|
let status = std::process::Command::new("tar")
|
||||||
@@ -107,6 +109,54 @@ fn install_version(config: &Config, tag: &str) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return all GE-Proton* directories found in `dir`.
|
||||||
|
fn scan_ge_proton_in(dir: &Path, seen: &mut HashSet<String>, out: &mut Vec<String>) {
|
||||||
|
let Ok(entries) = std::fs::read_dir(dir) else { return };
|
||||||
|
for entry in entries.flatten() {
|
||||||
|
if !entry.file_type().is_ok_and(|t| t.is_dir()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let name = entry.file_name().to_string_lossy().to_string();
|
||||||
|
if name.starts_with("GE-Proton") && seen.insert(name.clone()) {
|
||||||
|
out.push(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return all GE-Proton versions found in `dir`, newest-first,
|
||||||
|
/// prepended with "GE-Proton (latest)".
|
||||||
|
pub fn list_installed_from(dir: PathBuf) -> Vec<String> {
|
||||||
|
let mut seen = HashSet::new();
|
||||||
|
let mut versions = Vec::new();
|
||||||
|
scan_ge_proton_in(&dir, &mut seen, &mut versions);
|
||||||
|
versions.sort_by(|a, b| b.cmp(a));
|
||||||
|
let mut out = vec!["GE-Proton (latest)".to_string()];
|
||||||
|
out.extend(versions);
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return all GE-Proton versions found across the configured compat dir and
|
||||||
|
/// common system Proton locations (Steam, ProtonUp-Qt, /usr/share/steam).
|
||||||
|
pub fn list_installed(config: &Config) -> Vec<String> {
|
||||||
|
let mut dirs = vec![config.proton_compat_dir.clone()];
|
||||||
|
if let Some(home) = dirs::home_dir() {
|
||||||
|
// ProtonUp-Qt and manual installs land here by default
|
||||||
|
dirs.push(home.join(".steam/root/compatibilitytools.d"));
|
||||||
|
dirs.push(home.join(".local/share/Steam/compatibilitytools.d"));
|
||||||
|
}
|
||||||
|
dirs.push(PathBuf::from("/usr/share/steam/compatibilitytools.d"));
|
||||||
|
|
||||||
|
let mut seen = HashSet::new();
|
||||||
|
let mut versions = Vec::new();
|
||||||
|
for dir in &dirs {
|
||||||
|
scan_ge_proton_in(dir, &mut seen, &mut versions);
|
||||||
|
}
|
||||||
|
versions.sort_by(|a, b| b.cmp(a));
|
||||||
|
let mut out = vec!["GE-Proton (latest)".to_string()];
|
||||||
|
out.extend(versions);
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|
||||||
/// Install the latest GE-Proton release (called from tray menu).
|
/// Install the latest GE-Proton release (called from tray menu).
|
||||||
pub fn install_latest(config: &Config) -> Result<()> {
|
pub fn install_latest(config: &Config) -> Result<()> {
|
||||||
println!("Checking for latest GE-Proton...");
|
println!("Checking for latest GE-Proton...");
|
||||||
@@ -153,7 +203,7 @@ 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 { format!(" {}", "✓ installed".green().bold()) } else { String::new() };
|
||||||
println!(" {}{}", r.tag_name, marker);
|
println!(" {}{}", r.tag_name, marker);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -170,7 +220,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 +244,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 +267,7 @@ 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 { format!(" {}", "✓".green().bold()) } else { String::new() };
|
||||||
println!(" {:2}) {}{}", i + 1, r.tag_name, marker);
|
println!(" {:2}) {}{}", i + 1, r.tag_name, marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,98 +0,0 @@
|
|||||||
use anyhow::{bail, Context, Result};
|
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::process::Command;
|
|
||||||
|
|
||||||
const UNIT_NAME: &str = "umutray.service";
|
|
||||||
|
|
||||||
fn unit_path() -> Result<PathBuf> {
|
|
||||||
let home = std::env::var("HOME").context("$HOME is not set")?;
|
|
||||||
Ok(PathBuf::from(home)
|
|
||||||
.join(".config/systemd/user")
|
|
||||||
.join(UNIT_NAME))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn render_unit(exe: &std::path::Path) -> String {
|
|
||||||
format!(
|
|
||||||
"[Unit]\n\
|
|
||||||
Description=Battle.net tray manager\n\
|
|
||||||
After=graphical-session.target\n\
|
|
||||||
PartOf=graphical-session.target\n\
|
|
||||||
\n\
|
|
||||||
[Service]\n\
|
|
||||||
ExecStart={exe}\n\
|
|
||||||
Restart=on-failure\n\
|
|
||||||
RestartSec=5\n\
|
|
||||||
\n\
|
|
||||||
[Install]\n\
|
|
||||||
WantedBy=graphical-session.target\n",
|
|
||||||
exe = exe.display(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn systemctl(args: &[&str]) -> Result<()> {
|
|
||||||
let status = Command::new("systemctl")
|
|
||||||
.arg("--user")
|
|
||||||
.args(args)
|
|
||||||
.status()
|
|
||||||
.context("Failed to invoke systemctl --user (is systemd installed?)")?;
|
|
||||||
if !status.success() {
|
|
||||||
bail!("systemctl --user {} exited non-zero", args.join(" "));
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Write the unit, reload systemd, and enable+start the service.
|
|
||||||
pub fn install() -> Result<()> {
|
|
||||||
let exe = std::env::current_exe()
|
|
||||||
.context("Cannot determine path to own executable")?;
|
|
||||||
let path = unit_path()?;
|
|
||||||
|
|
||||||
if let Some(parent) = path.parent() {
|
|
||||||
std::fs::create_dir_all(parent)
|
|
||||||
.with_context(|| format!("Failed to create {parent:?}"))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
let contents = render_unit(&exe);
|
|
||||||
std::fs::write(&path, &contents)
|
|
||||||
.with_context(|| format!("Failed to write unit file {path:?}"))?;
|
|
||||||
println!("Wrote unit: {}", path.display());
|
|
||||||
println!("ExecStart: {}", exe.display());
|
|
||||||
println!();
|
|
||||||
|
|
||||||
systemctl(&["daemon-reload"])?;
|
|
||||||
systemctl(&["enable", "--now", UNIT_NAME])?;
|
|
||||||
|
|
||||||
println!();
|
|
||||||
println!("\x1b[1;32m✓\x1b[0m Service installed and started.");
|
|
||||||
println!(" Status: systemctl --user status {UNIT_NAME}");
|
|
||||||
println!(" Logs: journalctl --user -u {UNIT_NAME} -f");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Stop, disable, and remove the unit file.
|
|
||||||
pub fn uninstall() -> Result<()> {
|
|
||||||
let path = unit_path()?;
|
|
||||||
|
|
||||||
// Ignore failures: the unit may already be stopped or unknown to systemd.
|
|
||||||
let _ = systemctl(&["disable", "--now", UNIT_NAME]);
|
|
||||||
|
|
||||||
if path.exists() {
|
|
||||||
std::fs::remove_file(&path)
|
|
||||||
.with_context(|| format!("Failed to remove {path:?}"))?;
|
|
||||||
println!("Removed {}", path.display());
|
|
||||||
} else {
|
|
||||||
println!("No unit file at {}", path.display());
|
|
||||||
}
|
|
||||||
|
|
||||||
let _ = systemctl(&["daemon-reload"]);
|
|
||||||
println!("\x1b[1;32m✓\x1b[0m Service removed.");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Pass through `systemctl --user status`.
|
|
||||||
pub fn status() -> Result<()> {
|
|
||||||
let _ = Command::new("systemctl")
|
|
||||||
.args(["--user", "status", UNIT_NAME])
|
|
||||||
.status();
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
+1014
-53
File diff suppressed because it is too large
Load Diff
+208
@@ -0,0 +1,208 @@
|
|||||||
|
use iced::widget::{button, container, text};
|
||||||
|
use iced::{Background, Border, Color, Element, Shadow, Theme, Vector};
|
||||||
|
|
||||||
|
// ── Palette ────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
pub const ACCENT: Color = Color {
|
||||||
|
r: 0.49,
|
||||||
|
g: 0.55,
|
||||||
|
b: 0.97,
|
||||||
|
a: 1.0,
|
||||||
|
};
|
||||||
|
pub const GREEN: Color = Color {
|
||||||
|
r: 0.29,
|
||||||
|
g: 0.87,
|
||||||
|
b: 0.50,
|
||||||
|
a: 1.0,
|
||||||
|
};
|
||||||
|
pub const RED: Color = Color {
|
||||||
|
r: 0.97,
|
||||||
|
g: 0.44,
|
||||||
|
b: 0.44,
|
||||||
|
a: 1.0,
|
||||||
|
};
|
||||||
|
pub const MUTED: Color = Color {
|
||||||
|
r: 0.42,
|
||||||
|
g: 0.44,
|
||||||
|
b: 0.50,
|
||||||
|
a: 1.0,
|
||||||
|
};
|
||||||
|
pub const DIM: Color = Color {
|
||||||
|
r: 0.55,
|
||||||
|
g: 0.58,
|
||||||
|
b: 0.64,
|
||||||
|
a: 1.0,
|
||||||
|
};
|
||||||
|
pub const SURFACE: Color = Color {
|
||||||
|
r: 0.12,
|
||||||
|
g: 0.13,
|
||||||
|
b: 0.16,
|
||||||
|
a: 1.0,
|
||||||
|
};
|
||||||
|
pub const SURFACE_RAISED: Color = Color {
|
||||||
|
r: 0.15,
|
||||||
|
g: 0.16,
|
||||||
|
b: 0.19,
|
||||||
|
a: 1.0,
|
||||||
|
};
|
||||||
|
pub const BORDER_CLR: Color = Color {
|
||||||
|
r: 0.20,
|
||||||
|
g: 0.21,
|
||||||
|
b: 0.26,
|
||||||
|
a: 1.0,
|
||||||
|
};
|
||||||
|
|
||||||
|
// ── Helpers ────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/// Bootstrap-icon helper — keeps call sites tidy.
|
||||||
|
pub fn icon(codepoint: &str, size: u32) -> iced::widget::Text<'static> {
|
||||||
|
text(codepoint.to_owned())
|
||||||
|
.font(iced::Font::with_name("bootstrap-icons"))
|
||||||
|
.size(size)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Styled section heading (uppercase, dimmed).
|
||||||
|
pub fn section_heading<'a, M: 'a>(label: &str) -> Element<'a, M> {
|
||||||
|
text(label.to_uppercase())
|
||||||
|
.size(10)
|
||||||
|
.style(move |_: &Theme| text::Style { color: Some(DIM) })
|
||||||
|
.into()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Button styles ──────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/// Accent-filled primary button style.
|
||||||
|
pub fn btn_accent(_theme: &Theme, status: button::Status) -> button::Style {
|
||||||
|
let (bg, fg) = match status {
|
||||||
|
button::Status::Active => (ACCENT, Color::WHITE),
|
||||||
|
button::Status::Hovered => (Color { a: 0.85, ..ACCENT }, Color::WHITE),
|
||||||
|
_ => (
|
||||||
|
Color { a: 0.5, ..ACCENT },
|
||||||
|
Color {
|
||||||
|
a: 0.7,
|
||||||
|
..Color::WHITE
|
||||||
|
},
|
||||||
|
),
|
||||||
|
};
|
||||||
|
button::Style {
|
||||||
|
background: Some(Background::Color(bg)),
|
||||||
|
text_color: fg,
|
||||||
|
border: Border {
|
||||||
|
color: Color::TRANSPARENT,
|
||||||
|
width: 0.0,
|
||||||
|
radius: 8.0.into(),
|
||||||
|
},
|
||||||
|
shadow: NO_SHADOW,
|
||||||
|
snap: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const NO_SHADOW: Shadow = Shadow {
|
||||||
|
color: Color::TRANSPARENT,
|
||||||
|
offset: Vector::ZERO,
|
||||||
|
blur_radius: 0.0,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Ghost / outline secondary button style.
|
||||||
|
pub fn btn_ghost(_theme: &Theme, status: button::Status) -> button::Style {
|
||||||
|
let (bg, border_a) = match status {
|
||||||
|
button::Status::Hovered => (
|
||||||
|
Color { r: 0.22, g: 0.23, b: 0.28, a: 1.0 },
|
||||||
|
0.40,
|
||||||
|
),
|
||||||
|
button::Status::Pressed => (
|
||||||
|
Color { r: 0.25, g: 0.26, b: 0.31, a: 1.0 },
|
||||||
|
0.50,
|
||||||
|
),
|
||||||
|
_ => (
|
||||||
|
Color { r: 0.18, g: 0.19, b: 0.23, a: 1.0 },
|
||||||
|
0.25,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
button::Style {
|
||||||
|
background: Some(Background::Color(bg)),
|
||||||
|
text_color: Color {
|
||||||
|
r: 0.78,
|
||||||
|
g: 0.80,
|
||||||
|
b: 0.85,
|
||||||
|
a: 1.0,
|
||||||
|
},
|
||||||
|
border: Border {
|
||||||
|
color: Color { a: border_a, ..BORDER_CLR },
|
||||||
|
width: 1.0,
|
||||||
|
radius: 8.0.into(),
|
||||||
|
},
|
||||||
|
shadow: NO_SHADOW,
|
||||||
|
snap: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Red danger button style.
|
||||||
|
pub fn btn_danger(_theme: &Theme, status: button::Status) -> button::Style {
|
||||||
|
let (bg, fg) = match status {
|
||||||
|
button::Status::Active => (RED, Color::WHITE),
|
||||||
|
button::Status::Hovered => (Color { a: 0.85, ..RED }, Color::WHITE),
|
||||||
|
_ => (
|
||||||
|
Color { a: 0.5, ..RED },
|
||||||
|
Color {
|
||||||
|
a: 0.7,
|
||||||
|
..Color::WHITE
|
||||||
|
},
|
||||||
|
),
|
||||||
|
};
|
||||||
|
button::Style {
|
||||||
|
background: Some(Background::Color(bg)),
|
||||||
|
text_color: fg,
|
||||||
|
border: Border {
|
||||||
|
color: Color::TRANSPARENT,
|
||||||
|
width: 0.0,
|
||||||
|
radius: 8.0.into(),
|
||||||
|
},
|
||||||
|
shadow: NO_SHADOW,
|
||||||
|
snap: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Container styles ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/// Full-window background style.
|
||||||
|
pub fn surface_bg(_theme: &Theme) -> container::Style {
|
||||||
|
container::Style {
|
||||||
|
background: Some(Background::Color(SURFACE)),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Raised card style (12px radius, 1px border).
|
||||||
|
pub fn card_style(_theme: &Theme) -> container::Style {
|
||||||
|
container::Style {
|
||||||
|
background: Some(Background::Color(SURFACE_RAISED)),
|
||||||
|
border: Border {
|
||||||
|
color: BORDER_CLR,
|
||||||
|
width: 1.0,
|
||||||
|
radius: 12.0.into(),
|
||||||
|
},
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Inner sub-card style (darker background, subtle border, 8px radius).
|
||||||
|
pub fn sub_card_style(_theme: &Theme) -> container::Style {
|
||||||
|
container::Style {
|
||||||
|
background: Some(Background::Color(Color {
|
||||||
|
r: 0.11,
|
||||||
|
g: 0.12,
|
||||||
|
b: 0.15,
|
||||||
|
a: 0.8,
|
||||||
|
})),
|
||||||
|
border: Border {
|
||||||
|
color: Color {
|
||||||
|
a: 0.15,
|
||||||
|
..BORDER_CLR
|
||||||
|
},
|
||||||
|
width: 1.0,
|
||||||
|
radius: 8.0.into(),
|
||||||
|
},
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
+208
-16
@@ -4,13 +4,90 @@ use std::collections::HashMap;
|
|||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
fn spawn_setup(config: &Config, name: &str) {
|
||||||
|
let config = config.clone();
|
||||||
|
let name = name.to_owned();
|
||||||
|
thread::spawn(move || {
|
||||||
|
if let Some(l) = config.find(&name) {
|
||||||
|
let l = l.clone();
|
||||||
|
if let Err(e) = crate::setup::run(&config, &l) {
|
||||||
|
eprintln!("umutray: setup for {name} failed: {e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn spawn_gui(config: &Config) {
|
||||||
|
let config = config.clone();
|
||||||
|
thread::spawn(move || {
|
||||||
|
match crate::gui::run(&config) {
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(e) => eprintln!("umutray: failed to launch dashboard: {e}"),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn spawn_setup_picker(config: &Config) {
|
||||||
|
let config = config.clone();
|
||||||
|
thread::spawn(move || {
|
||||||
|
if let Err(e) = crate::setup::run_new(&config) {
|
||||||
|
eprintln!("umutray: failed to launch setup picker: {e}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
enum GameFlag {
|
||||||
|
GameMode,
|
||||||
|
MangoHud,
|
||||||
|
Gamescope,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn toggle_flag(this: &mut UmuTray, launcher: &str, game: &str, flag: GameFlag) {
|
||||||
|
for l in this.config.launchers.iter_mut() {
|
||||||
|
if l.name != launcher {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for g in l.games.iter_mut() {
|
||||||
|
if g.name != game {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
match flag {
|
||||||
|
GameFlag::GameMode => g.gamemode = !g.gamemode,
|
||||||
|
GameFlag::MangoHud => g.mangohud = !g.mangohud,
|
||||||
|
GameFlag::Gamescope => {
|
||||||
|
g.gamescope = if g.gamescope.is_some() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(vec![])
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Err(e) = this.config.save() {
|
||||||
|
eprintln!("umutray: failed to persist flag toggle: {e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn play_from_tray(config: &Config, launcher: &str, game: &str) {
|
||||||
|
let Some(l) = config.find(launcher) else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let Some(g) = l.find_game(game) else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
if let Err(e) = crate::launcher::play_game(config, l, g) {
|
||||||
|
eprintln!("umutray: play {game} failed: {e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct UmuTray {
|
pub struct UmuTray {
|
||||||
pub config: Config,
|
pub config: Config,
|
||||||
/// Per-launcher running state keyed by launcher.name
|
/// Per-launcher running state keyed by launcher.name
|
||||||
pub running: HashMap<String, bool>,
|
pub running: HashMap<String, bool>,
|
||||||
/// Set after the service spawns so Quit can shut down the SNI item
|
/// Set after the tray spawns so Quit can shut down the SNI item
|
||||||
/// cleanly instead of yanking it off the bus via exit().
|
/// cleanly instead of yanking it off the bus via exit().
|
||||||
pub handle: Option<ksni::Handle<UmuTray>>,
|
pub handle: Option<ksni::blocking::Handle<UmuTray>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ksni::Tray for UmuTray {
|
impl ksni::Tray for UmuTray {
|
||||||
@@ -19,7 +96,7 @@ impl ksni::Tray for UmuTray {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn icon_name(&self) -> String {
|
fn icon_name(&self) -> String {
|
||||||
"applications-games".into()
|
"umutray".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn title(&self) -> String {
|
fn title(&self) -> String {
|
||||||
@@ -32,7 +109,16 @@ impl ksni::Tray for UmuTray {
|
|||||||
|
|
||||||
fn menu(&self) -> Vec<ksni::MenuItem<Self>> {
|
fn menu(&self) -> Vec<ksni::MenuItem<Self>> {
|
||||||
use ksni::menu::*;
|
use ksni::menu::*;
|
||||||
let mut items: Vec<ksni::MenuItem<Self>> = vec![];
|
let mut items: Vec<ksni::MenuItem<Self>> = vec![
|
||||||
|
StandardItem {
|
||||||
|
label: "Open Dashboard".into(),
|
||||||
|
icon_name: "applications-games".into(),
|
||||||
|
activate: Box::new(|this: &mut Self| spawn_gui(&this.config)),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
ksni::MenuItem::Separator,
|
||||||
|
];
|
||||||
|
|
||||||
for l in &self.config.launchers {
|
for l in &self.config.launchers {
|
||||||
let installed = l.full_exe_path().exists();
|
let installed = l.full_exe_path().exists();
|
||||||
@@ -41,10 +127,14 @@ impl ksni::Tray for UmuTray {
|
|||||||
let display = l.display.clone();
|
let display = l.display.clone();
|
||||||
|
|
||||||
if !installed {
|
if !installed {
|
||||||
|
let setup_name = name.clone();
|
||||||
items.push(
|
items.push(
|
||||||
StandardItem {
|
StandardItem {
|
||||||
label: format!("{display} (not installed)"),
|
label: format!("Setup {display}…"),
|
||||||
enabled: false,
|
icon_name: "document-new".into(),
|
||||||
|
activate: Box::new(move |this: &mut Self| {
|
||||||
|
spawn_setup(&this.config, &setup_name);
|
||||||
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.into(),
|
.into(),
|
||||||
@@ -53,13 +143,14 @@ impl ksni::Tray for UmuTray {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if running {
|
if running {
|
||||||
|
let kill_name = name.clone();
|
||||||
items.push(
|
items.push(
|
||||||
StandardItem {
|
StandardItem {
|
||||||
label: format!("Kill {display}"),
|
label: format!("Kill {display}"),
|
||||||
icon_name: "process-stop".into(),
|
icon_name: "process-stop".into(),
|
||||||
activate: Box::new(move |this: &mut Self| {
|
activate: Box::new(move |this: &mut Self| {
|
||||||
if let Some(l) = this.config.find(&name) {
|
if let Some(l) = this.config.find(&kill_name) {
|
||||||
let _ = launcher::kill(l);
|
launcher::kill(l);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
@@ -67,12 +158,13 @@ impl ksni::Tray for UmuTray {
|
|||||||
.into(),
|
.into(),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
let launch_name = name.clone();
|
||||||
items.push(
|
items.push(
|
||||||
StandardItem {
|
StandardItem {
|
||||||
label: format!("Launch {display}"),
|
label: format!("Launch {display}"),
|
||||||
icon_name: "media-playback-start".into(),
|
icon_name: "media-playback-start".into(),
|
||||||
activate: Box::new(move |this: &mut Self| {
|
activate: Box::new(move |this: &mut Self| {
|
||||||
if let Some(l) = this.config.find(&name) {
|
if let Some(l) = this.config.find(&launch_name) {
|
||||||
if let Err(e) = launcher::launch(&this.config, l) {
|
if let Err(e) = launcher::launch(&this.config, l) {
|
||||||
eprintln!("umutray: launch {} failed: {e}", l.name);
|
eprintln!("umutray: launch {} failed: {e}", l.name);
|
||||||
}
|
}
|
||||||
@@ -83,6 +175,87 @@ impl ksni::Tray for UmuTray {
|
|||||||
.into(),
|
.into(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Per-game submenus with Play + overlay toggles.
|
||||||
|
for g in &l.games {
|
||||||
|
let gdisplay = g.display.clone();
|
||||||
|
let gname_play = g.name.clone();
|
||||||
|
let lname_play = name.clone();
|
||||||
|
let gname_gm = g.name.clone();
|
||||||
|
let lname_gm = name.clone();
|
||||||
|
let gname_mh = g.name.clone();
|
||||||
|
let lname_mh = name.clone();
|
||||||
|
let gname_gs = g.name.clone();
|
||||||
|
let lname_gs = name.clone();
|
||||||
|
|
||||||
|
let mut sub: Vec<ksni::MenuItem<Self>> = Vec::new();
|
||||||
|
sub.push(
|
||||||
|
StandardItem {
|
||||||
|
label: format!("Play {gdisplay}"),
|
||||||
|
icon_name: "media-playback-start".into(),
|
||||||
|
activate: Box::new(move |this: &mut Self| {
|
||||||
|
play_from_tray(&this.config, &lname_play, &gname_play);
|
||||||
|
}),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
);
|
||||||
|
sub.push(ksni::MenuItem::Separator);
|
||||||
|
sub.push(
|
||||||
|
CheckmarkItem {
|
||||||
|
label: "GameMode".into(),
|
||||||
|
checked: g.gamemode,
|
||||||
|
activate: Box::new(move |this: &mut Self| {
|
||||||
|
toggle_flag(this, &lname_gm, &gname_gm, GameFlag::GameMode);
|
||||||
|
}),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
);
|
||||||
|
sub.push(
|
||||||
|
CheckmarkItem {
|
||||||
|
label: "MangoHud".into(),
|
||||||
|
checked: g.mangohud,
|
||||||
|
activate: Box::new(move |this: &mut Self| {
|
||||||
|
toggle_flag(this, &lname_mh, &gname_mh, GameFlag::MangoHud);
|
||||||
|
}),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
);
|
||||||
|
sub.push(
|
||||||
|
CheckmarkItem {
|
||||||
|
label: "Gamescope".into(),
|
||||||
|
checked: g.gamescope.is_some(),
|
||||||
|
activate: Box::new(move |this: &mut Self| {
|
||||||
|
toggle_flag(this, &lname_gs, &gname_gs, GameFlag::Gamescope);
|
||||||
|
}),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
);
|
||||||
|
|
||||||
|
items.push(
|
||||||
|
SubMenu {
|
||||||
|
label: gdisplay,
|
||||||
|
submenu: sub,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.config.launchers.is_empty() {
|
||||||
|
items.push(
|
||||||
|
StandardItem {
|
||||||
|
label: "Add Launcher…".into(),
|
||||||
|
icon_name: "list-add".into(),
|
||||||
|
activate: Box::new(|this: &mut Self| spawn_setup_picker(&this.config)),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
items.push(ksni::MenuItem::Separator);
|
items.push(ksni::MenuItem::Separator);
|
||||||
@@ -131,6 +304,26 @@ impl ksni::Tray for UmuTray {
|
|||||||
|
|
||||||
/// Start the system tray daemon. Blocks until the process is killed.
|
/// Start the system tray daemon. Blocks until the process is killed.
|
||||||
pub fn run(config: &Config) -> Result<()> {
|
pub fn run(config: &Config) -> Result<()> {
|
||||||
|
let _handle = spawn(config);
|
||||||
|
loop {
|
||||||
|
thread::sleep(Duration::from_secs(60));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A handle that can shut down the tray from another thread.
|
||||||
|
pub struct TrayHandle {
|
||||||
|
inner: ksni::blocking::Handle<UmuTray>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TrayHandle {
|
||||||
|
pub fn shutdown(&self) {
|
||||||
|
let h = self.inner.clone();
|
||||||
|
thread::spawn(move || h.shutdown());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Spawn the tray icon in the background and return a handle to shut it down.
|
||||||
|
pub fn spawn(config: &Config) -> TrayHandle {
|
||||||
let mut running = HashMap::new();
|
let mut running = HashMap::new();
|
||||||
for l in &config.launchers {
|
for l in &config.launchers {
|
||||||
running.insert(l.name.clone(), launcher::is_running(l));
|
running.insert(l.name.clone(), launcher::is_running(l));
|
||||||
@@ -142,9 +335,10 @@ pub fn run(config: &Config) -> Result<()> {
|
|||||||
handle: None,
|
handle: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let service = ksni::TrayService::new(tray);
|
let handle = {
|
||||||
let handle = service.handle();
|
use ksni::blocking::TrayMethods;
|
||||||
service.spawn();
|
tray.spawn().expect("Failed to spawn tray service")
|
||||||
|
};
|
||||||
|
|
||||||
// Hand the tray a clone of its own handle so Quit can shut down cleanly.
|
// Hand the tray a clone of its own handle so Quit can shut down cleanly.
|
||||||
let handle_for_self = handle.clone();
|
let handle_for_self = handle.clone();
|
||||||
@@ -154,7 +348,7 @@ pub fn run(config: &Config) -> Result<()> {
|
|||||||
|
|
||||||
// Background thread: poll every configured launcher's state every 2 s
|
// Background thread: poll every configured launcher's state every 2 s
|
||||||
// and push the snapshot to the tray.
|
// and push the snapshot to the tray.
|
||||||
let poll_handle = handle;
|
let poll_handle = handle.clone();
|
||||||
let launchers = config.launchers.clone();
|
let launchers = config.launchers.clone();
|
||||||
thread::spawn(move || loop {
|
thread::spawn(move || loop {
|
||||||
let mut snapshot: HashMap<String, bool> = HashMap::new();
|
let mut snapshot: HashMap<String, bool> = HashMap::new();
|
||||||
@@ -167,7 +361,5 @@ pub fn run(config: &Config) -> Result<()> {
|
|||||||
thread::sleep(Duration::from_secs(2));
|
thread::sleep(Duration::from_secs(2));
|
||||||
});
|
});
|
||||||
|
|
||||||
loop {
|
TrayHandle { inner: handle }
|
||||||
thread::sleep(Duration::from_secs(60));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
/// Open a native folder picker dialog and return the chosen path, or None if
|
||||||
|
/// the user cancelled. Uses XDG Desktop Portal where available.
|
||||||
|
pub fn pick_folder(title: &str) -> Option<String> {
|
||||||
|
rfd::FileDialog::new()
|
||||||
|
.set_title(title)
|
||||||
|
.pick_folder()
|
||||||
|
.map(|p| p.to_string_lossy().into_owned())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Open a native file picker dialog starting in `start_dir`, or None if
|
||||||
|
/// the user cancelled. Uses XDG Desktop Portal where available.
|
||||||
|
pub fn pick_file(title: &str, start_dir: &str) -> Option<String> {
|
||||||
|
rfd::FileDialog::new()
|
||||||
|
.set_title(title)
|
||||||
|
.set_directory(start_dir)
|
||||||
|
.pick_file()
|
||||||
|
.map(|p| p.to_string_lossy().into_owned())
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Name=umutray
|
||||||
|
Comment=Wine launcher manager for Windows game launchers
|
||||||
|
Exec=umutray gui
|
||||||
|
Icon=umutray
|
||||||
|
Type=Application
|
||||||
|
Categories=Game;
|
||||||
|
Keywords=wine;proton;gaming;launcher;
|
||||||
|
StartupNotify=true
|
||||||
Reference in New Issue
Block a user