// nixos-config - My current NixOS configuration // // Copyright (C) 2025 Benedikt Peetz // SPDX-License-Identifier: GPL-3.0-or-later // // This file is part of my nixos-config. // // You should have received a copy of the License along with this program. // If not, see . use std::{env::args, process::Command}; use anyhow::{Context, Result}; fn main() -> Result<()> { let args = args().skip(1).collect::>(); let mut cmd = Command::new(&args[0]); cmd.args(&args[1..]); eprintln!("Spawning {:?}", cmd); let output = cmd .output() .with_context(|| format!("Failed to spawn and await output of {:?}", cmd))?; if !output.status.success() { let mut notify_send = Command::new("notify-send"); notify_send.args([ format!("Command {:?} failed", cmd).as_str(), &String::from_utf8_lossy(output.stderr.as_slice()), ]); notify_send.status().with_context(|| { format!( "Failed to run `notify-send` to tell about failed command ({:?}).", cmd ) })?; } else { print!("{}", String::from_utf8_lossy(&output.stdout)); eprint!("{}", String::from_utf8_lossy(&output.stderr)); } Ok(()) }