From 41199b2f092f6a3adb0b4b490e5675122839c944 Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Sat, 26 Jun 2021 00:21:34 +0200 Subject: [PATCH] Actually react to urgency and impove default config --- src/con.rs | 18 ++++++++++++++++-- src/config.rs | 20 +++++++++++++------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/con.rs b/src/con.rs index 5cc5233..d0ff4cd 100644 --- a/src/con.rs +++ b/src/con.rs @@ -149,8 +149,22 @@ impl<'a> DisplayFormat for Window<'a> { }); fmt.replace("{id}", format!("{}", self.get_id()).as_str()) - .replace("{urgency_start}", urgency_start.as_str()) - .replace("{urgency_end}", urgency_end.as_str()) + .replace( + "{urgency_start}", + if self.is_urgent() { + urgency_start.as_str() + } else { + "" + }, + ) + .replace( + "{urgency_end}", + if self.is_urgent() { + urgency_end.as_str() + } else { + "" + }, + ) .replace("{app_name}", self.get_app_name()) .replace( "{workspace_name}", diff --git a/src/config.rs b/src/config.rs index 4fdc4cc..1c8cc09 100644 --- a/src/config.rs +++ b/src/config.rs @@ -28,12 +28,12 @@ impl Default for Config { }), format: Some(Format { window_format: Some( - "\"{title}\"\t{app_name} on workspace {workspace_name}\t({id})" + "{urgency_start}“{title}”{urgency_end}\t{app_name} on workspace {workspace_name}\t({id})" .to_string(), ), - workspace_format: Some("Workspace {name}\t({id})".to_string()), - urgency_start: Some(String::new()), - urgency_end: Some(String::new()) + workspace_format: Some("Workspace {name}\t({id})".to_string()), + urgency_start: Some("".to_string()), + urgency_end: Some("".to_string()) }), } } @@ -84,13 +84,19 @@ pub fn load_config() -> Config { save_config(Config::default()); // Tell the user that a fresh default config has been created. std::process::Command::new("swaynag") + .arg("--background") + .arg("00FF44") + .arg("--text") + .arg("0000CC") .arg("--message") .arg( - "Welcome to swayr. ".to_owned() - + "I've created a fresh (but boring) config for you in " + "Welcome to swayr! ".to_owned() + + "I've created a fresh config for use with wofi for you in " + &path.to_string_lossy() - + ".", + + ". Adapt it to your needs.", ) + .arg("--type") + .arg("warning") .arg("--dismiss-button") .arg("Thanks!") .spawn()