Skip to content

Commit debc02a

Browse files
committed
Add support for separator
1 parent f142ec6 commit debc02a

File tree

5 files changed

+27
-9
lines changed

5 files changed

+27
-9
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ MyNiceProgram = "😛"
6565
[aliases]
6666
TelegramDesktop = "Telegram"
6767
"Org.gnome.Nautilus" = "Nautilus"
68+
69+
[general]
70+
seperator = ""
6871
```
6972

7073
For an overview of available options

assets/example_config.toml

+3
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ MyNiceProgram = "😛"
1010
[aliases]
1111
TelegramDesktop = "Telegram"
1212
"Org.gnome.Nautilus" = "Nautilus"
13+
14+
[general]
15+
separator = ""

src/config.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,23 @@ use serde::Deserialize;
55
use failure::Error;
66

77
lazy_static! {
8-
pub static ref EMPTY_ALIASES_MAP: Map<String, String> = Map::new();
8+
pub static ref EMPTY_MAP: Map<String, String> = Map::new();
99
}
1010

1111
#[serde(default)]
1212
#[derive(Deserialize)]
1313
pub struct Config {
1414
pub icons: Map<String, char>,
1515
pub aliases: Map<String, String>,
16+
pub general: Map<String, String>
1617
}
1718

1819
impl Default for Config {
1920
fn default() -> Self {
2021
Config {
2122
icons: super::icons::NONE.clone(),
22-
aliases: EMPTY_ALIASES_MAP.clone(),
23+
aliases: EMPTY_MAP.clone(),
24+
general: EMPTY_MAP.clone()
2325
}
2426
}
2527
}

src/lib.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,17 @@ pub mod config;
3131
pub struct Options {
3232
pub icons: Map<String, char>,
3333
pub aliases: Map<String, String>,
34-
pub names: bool,
34+
pub general: Map<String, String>,
35+
pub names: bool
3536
}
3637

3738
impl Default for Options {
3839
fn default() -> Self {
3940
Options {
4041
icons: icons::NONE.clone(),
41-
aliases: config::EMPTY_ALIASES_MAP.clone(),
42-
names: true,
42+
aliases: config::EMPTY_MAP.clone(),
43+
general: config::EMPTY_MAP.clone(),
44+
names: true
4345
}
4446
}
4547
}
@@ -180,7 +182,13 @@ fn get_classes(workspace: &Node, x_conn: &xcb::Connection, options: &Options) ->
180182
pub fn update_tree(x_conn: &xcb::Connection, i3_conn: &mut I3Connection, options: &Options) -> Result<(), Error> {
181183
let tree = i3_conn.get_tree()?;
182184
for workspace in get_workspaces(tree) {
183-
let classes = get_classes(&workspace, &x_conn, options)?.join("|");
185+
186+
let separator = match options.general.get("separator") {
187+
Some(s) => s,
188+
None => "|"
189+
};
190+
191+
let classes = get_classes(&workspace, &x_conn, options)?.join(separator);
184192

185193
let old: String = workspace
186194
.name

src/main.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ fn main() -> Result<(), ExitFailure> {
4242
i3wsr::Options {
4343
icons: file_config.icons.into_iter().chain(i3wsr::icons::get_icons(&icons)).collect(),
4444
aliases: file_config.aliases,
45-
names: !no_names,
45+
general: file_config.general,
46+
names: !no_names
4647
}
4748
},
4849
None => {
4950
i3wsr::Options {
5051
icons: i3wsr::icons::get_icons(&icons),
51-
aliases: i3wsr::config::EMPTY_ALIASES_MAP.clone(),
52-
names: !no_names,
52+
aliases: i3wsr::config::EMPTY_MAP.clone(),
53+
general: i3wsr::config::EMPTY_MAP.clone(),
54+
names: !no_names
5355
}
5456
}
5557
};

0 commit comments

Comments
 (0)