Please disregard this patch. The sysfs path used here provides the ACTIVE vt,
so will yield wrong results for agreety instances running in a background vt.
diff --git a/agreety/src/main.rs b/agreety/src/main.rs
index 67a87bf..1721c49 100644
--- a/agreety/src/main.rs+++ b/agreety/src/main.rs
@@ -32,18 +32,28 @@ fn get_distro_name() -> Result<String, Box<dyn std::error::Error>> {
maybe_unquote(general.get("PRETTY_NAME").ok_or("no pretty name")?)
}
+/// Returns the current VT. May contain trailing whitespace.+fn get_vt() -> String {+ if let Ok(vtnr) = env::var("XDG_VTNR") {+ format!("tty{vtnr}")+ } else {+ if let Ok(tty) = std::fs::read_to_string("/sys/class/tty/tty0/active") {+ tty+ } else {+ String::from("tty0")+ }+ }+}+fn get_issue() -> Result<String, Box<dyn std::error::Error>> {
- let vtnr: usize = env::var("XDG_VTNR")- .unwrap_or_else(|_| "0".to_string())- .parse()- .expect("unable to parse VTNR");+ let vt = get_vt(); let uts = uname()?;
Ok(fs::read_to_string("/etc/issue")?
.replace(
"\\S",
&get_distro_name().unwrap_or_else(|_| "Linux".to_string()),
)
- .replace("\\l", &format!("tty{vtnr}"))+ .replace("\\l", vt.trim()) .replace("\\s", uts.sysname().to_str().unwrap())
.replace("\\r", uts.release().to_str().unwrap())
.replace("\\v", uts.version().to_str().unwrap())
--
2.44.0