1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-06-03 17:14:08 +02:00

preset apps

This commit is contained in:
Robin Appelman 2023-07-16 17:19:21 +02:00
commit 3d6615c528
3 changed files with 15 additions and 1 deletions

View file

@ -130,6 +130,11 @@ in {
type = types.str; type = types.str;
description = "Name of the preset"; description = "Name of the preset";
}; };
apps = mkOption {
type = types.listOf types.str;
description = "Apps to enable when the preset is enabled";
default = [];
};
commands = mkOption { commands = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
description = "Commands to run post setup when the preset is enabled"; description = "Commands to run post setup when the preset is enabled";

View file

@ -208,5 +208,8 @@ impl HazeConfig {
#[derive(Default, Deserialize, Debug)] #[derive(Default, Deserialize, Debug)]
pub struct Preset { pub struct Preset {
pub name: String, pub name: String,
#[serde(default)]
pub apps: Vec<String>,
#[serde(default)]
pub commands: Vec<String>, pub commands: Vec<String>,
} }

View file

@ -234,6 +234,12 @@ impl ServiceTrait for PresetService {
) -> Result<Vec<String>> { ) -> Result<Vec<String>> {
let preset = let preset =
get_preset(&config.preset, &self.0).ok_or_else(|| Report::msg("invalid preset"))?; get_preset(&config.preset, &self.0).ok_or_else(|| Report::msg("invalid preset"))?;
Ok(preset.commands.clone()) let mut commands: Vec<_> = preset
.apps
.iter()
.map(|app| format!("occ app:enable {app} --force"))
.collect();
commands.extend_from_slice(&preset.commands);
Ok(commands)
} }
} }