diff --git a/README.md b/README.md index eb88103..78ef714 100644 --- a/README.md +++ b/README.md @@ -231,6 +231,11 @@ display_property = "instance" Possible options are `class`, `instance`, and `name`, and will default to `class` if not present. +You can alternatively supply cmd argument: + +```sh +i3wsr --display-property instance +``` ### Icons You can configure icons for your WM property, a very basic preset for diff --git a/src/lib.rs b/src/lib.rs index b5f5533..d836967 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,15 +32,8 @@ fn get_title( let wm_instance = props.get(&WindowProperty::Instance); let wm_name = props.get(&WindowProperty::Title); let display_prop = match config.general.get("display_property") { - Some(prop) => { - match prop.as_ref() { - "class" | "instance" | "name" => prop, - _ => "class" - } - }, - None => { - "class" - } + Some(prop) => prop, + None => "class", }; // Check for aliases using pre-compiled regex diff --git a/src/main.rs b/src/main.rs index 9db27ca..332c138 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,13 @@ enum Icons { Awesome, } +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Debug)] +enum Properties { + Class, + Instance, + Name, +} + /// i3wsr config #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] @@ -34,6 +41,10 @@ struct Args { #[arg(short, long)] remove_duplicates: bool, + /// Which window property to use when no alias is found + #[arg(short = 'p', long)] + display_property: Option, + /// What character used to split the workspace title string #[arg(short = 'a', long)] split_at: Option, @@ -95,6 +106,18 @@ fn setup() -> Result> { config.general.insert("split_at".to_string(), split_char); } + // wm property + let display_property = match args.display_property { + Some(prop) => match prop { + Properties::Class => String::from("class"), + Properties::Instance => String::from("instance"), + Properties::Name => String::from("name"), + }, + None => String::from("class"), + }; + config + .general + .insert("display_property".to_string(), display_property); Ok(config) }