- systemd Automatic Boot Assessment: BLS +<tries> parsing/formatting and phoebus-boot-confirm.service - Preflight safety gates: 10 GiB storage preflight check and atomic @ and @var pre-update snapshots - Tiered update channels: Core, Proven (default), Edge - Userspace AI agent framework: agent_jail Bubblewrap isolation, desktop_config undoable mutations, phoebus-mcp server, sys propose staging bridge - Fixed parent directory creation race condition in personal storage - Verified with cargo fmt, clippy, and full workspace test suite
157 lines
4.9 KiB
Rust
157 lines
4.9 KiB
Rust
//! `phoebus-desktop` - Safe, typed desktop configuration utility for MangoWM + DMS.
|
|
//!
|
|
//! Provides schema-validated inspection, theme updating, and keybinding management
|
|
//! with automatic checkpointing and one-click undo support.
|
|
|
|
use std::path::PathBuf;
|
|
use std::process::ExitCode;
|
|
|
|
use clap::{Parser, Subcommand};
|
|
use phoebus_executor::desktop_config::{
|
|
add_mango_keybinding, apply_dms_theme, dms_config_dir_for_home, undo_latest_checkpoint,
|
|
DmsThemeConfig, MangoKeybinding,
|
|
};
|
|
|
|
#[derive(Parser, Debug)]
|
|
#[command(
|
|
name = "phoebus-desktop",
|
|
about = "Safe desktop configuration and checkpoint manager for MangoWM + DMS",
|
|
version
|
|
)]
|
|
struct Cli {
|
|
/// Override the user's home directory.
|
|
#[arg(long)]
|
|
home: Option<PathBuf>,
|
|
|
|
#[command(subcommand)]
|
|
command: Commands,
|
|
}
|
|
|
|
#[derive(Subcommand, Debug)]
|
|
enum Commands {
|
|
/// Manage DarkMaterialShell themes.
|
|
Theme {
|
|
#[command(subcommand)]
|
|
sub: ThemeCommands,
|
|
},
|
|
/// Manage MangoWM keybindings.
|
|
Keybinding {
|
|
#[command(subcommand)]
|
|
sub: KeybindingCommands,
|
|
},
|
|
/// Revert the latest desktop configuration modification.
|
|
Undo,
|
|
}
|
|
|
|
#[derive(Subcommand, Debug)]
|
|
enum ThemeCommands {
|
|
/// Get the current DMS theme configuration.
|
|
Get,
|
|
/// Set theme properties with an automatic undo checkpoint.
|
|
Set {
|
|
/// Accent color hex string (e.g. #7aa2f7).
|
|
#[arg(long)]
|
|
accent: Option<String>,
|
|
/// Enable or disable dark mode.
|
|
#[arg(long)]
|
|
dark: Option<bool>,
|
|
/// Path to the desktop wallpaper image.
|
|
#[arg(long)]
|
|
wallpaper: Option<String>,
|
|
},
|
|
}
|
|
|
|
#[derive(Subcommand, Debug)]
|
|
enum KeybindingCommands {
|
|
/// Add a keybinding to MangoWM config with an automatic undo checkpoint.
|
|
Add {
|
|
/// Key combination (e.g. Mod4+Return).
|
|
#[arg(long)]
|
|
combo: String,
|
|
/// Action to execute (e.g. spawn kitty).
|
|
#[arg(long)]
|
|
action: String,
|
|
},
|
|
}
|
|
|
|
fn main() -> ExitCode {
|
|
let cli = Cli::parse();
|
|
let home = cli.home.unwrap_or_else(|| {
|
|
std::env::var("HOME")
|
|
.map(PathBuf::from)
|
|
.unwrap_or_else(|_| PathBuf::from("."))
|
|
});
|
|
|
|
match cli.command {
|
|
Commands::Theme { sub } => match sub {
|
|
ThemeCommands::Get => {
|
|
let theme_file = dms_config_dir_for_home(&home).join("theme.json");
|
|
if theme_file.exists() {
|
|
match std::fs::read_to_string(&theme_file) {
|
|
Ok(content) => {
|
|
println!("{content}");
|
|
ExitCode::SUCCESS
|
|
}
|
|
Err(e) => {
|
|
eprintln!("phoebus-desktop: error reading theme: {e}");
|
|
ExitCode::FAILURE
|
|
}
|
|
}
|
|
} else {
|
|
println!("Default DMS theme (no custom theme.json found).");
|
|
ExitCode::SUCCESS
|
|
}
|
|
}
|
|
ThemeCommands::Set {
|
|
accent,
|
|
dark,
|
|
wallpaper,
|
|
} => {
|
|
let theme = DmsThemeConfig {
|
|
accent_color: accent,
|
|
dark_mode: dark,
|
|
wallpaper_path: wallpaper,
|
|
};
|
|
|
|
match apply_dms_theme(&home, &theme) {
|
|
Ok(()) => {
|
|
println!("Theme applied successfully. Automatic checkpoint saved.");
|
|
ExitCode::SUCCESS
|
|
}
|
|
Err(e) => {
|
|
eprintln!("phoebus-desktop: error applying theme: {e}");
|
|
ExitCode::FAILURE
|
|
}
|
|
}
|
|
}
|
|
},
|
|
Commands::Keybinding { sub } => match sub {
|
|
KeybindingCommands::Add { combo, action } => {
|
|
let kb = MangoKeybinding { combo, action };
|
|
match add_mango_keybinding(&home, &kb) {
|
|
Ok(()) => {
|
|
println!(
|
|
"Keybinding '{}' added successfully. Automatic checkpoint saved.",
|
|
kb.combo
|
|
);
|
|
ExitCode::SUCCESS
|
|
}
|
|
Err(e) => {
|
|
eprintln!("phoebus-desktop: error adding keybinding: {e}");
|
|
ExitCode::FAILURE
|
|
}
|
|
}
|
|
}
|
|
},
|
|
Commands::Undo => match undo_latest_checkpoint(&home) {
|
|
Ok(restored) => {
|
|
println!("Successfully restored desktop checkpoint: {restored}");
|
|
ExitCode::SUCCESS
|
|
}
|
|
Err(e) => {
|
|
eprintln!("phoebus-desktop: undo failed: {e}");
|
|
ExitCode::FAILURE
|
|
}
|
|
},
|
|
}
|
|
}
|