Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ fn migrate_config_file(

pub fn create_default_config(cfg_path: &PathBuf) -> Result<String, Box<dyn Error + 'static>> {
// TODO: maybe we should dump the config from the default values of the struct?
let default_config = format!(r#"version = "{VERSION}"
let default_config = format!(
r#"version = "{VERSION}"

# [format]
# Deduplicate icons if enable.
Expand Down Expand Up @@ -349,7 +350,8 @@ aProgram = "^$" # will match null title for aProgram
9 = "nine"
10 = "ten"

"#);
"#
);

let mut config_file = File::create(cfg_path)?;
write!(&mut config_file, "{}", default_config.trim())?;
Expand Down
13 changes: 7 additions & 6 deletions src/renamer/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ use crate::renamer::ConfigFile;
use crate::renamer::IconStatus::*;
use crate::{AppClient, Renamer};
use hyprland::data::FullscreenMode;
use hyprland::shared::WorkspaceType;
use std::collections::HashMap;
use strfmt::strfmt;

#[derive(Clone)]
pub struct AppWorkspace {
pub id: i32,
pub id: WorkspaceType,
pub clients: Vec<AppClient>,
}

impl AppWorkspace {
pub fn new(id: i32, clients: Vec<AppClient>) -> Self {
pub fn new(id: WorkspaceType, clients: Vec<AppClient>) -> Self {
AppWorkspace { id, clients }
}
}
Expand All @@ -22,7 +23,7 @@ impl Renamer {
&self,
workspaces: Vec<AppWorkspace>,
config: &ConfigFile,
) -> HashMap<i32, String> {
) -> HashMap<WorkspaceType, String> {
let vars = HashMap::from([("delim".to_string(), config.format.delim.to_string())]);
workspaces
.iter()
Expand Down Expand Up @@ -70,7 +71,7 @@ impl Renamer {
let delimiter = formatter("{delim}", &vars);
let joined_string = workspace_output.join(&delimiter);

(workspace.id, joined_string)
(workspace.id.clone(), joined_string)
})
.collect()
}
Expand Down Expand Up @@ -231,9 +232,9 @@ mod tests {
is_dedup_inactive_fullscreen: false,
};

let workspace = AppWorkspace::new(1, vec![client]);
let workspace = AppWorkspace::new(WorkspaceType::try_from(1).unwrap(), vec![client]);

assert_eq!(workspace.id, 1);
assert_eq!(workspace.id, WorkspaceType::Regular("1".to_string()));
assert_eq!(workspace.clients.len(), 1);
assert_eq!(workspace.clients[0].class, "Class");
assert_eq!(workspace.clients[0].title, "Title");
Expand Down
Loading
Loading