Use a more explicit "terminator" for --regex-cmd

This commit is contained in:
Stephen Seo 2022-07-12 17:51:44 +09:00
parent 6d18f98779
commit 3f1b7df7f4
2 changed files with 3 additions and 3 deletions

View file

@ -21,8 +21,8 @@ Put the following in your `~/.config/sway/config`:
# cause the program to omit network traffic stats.
status_command $HOME/.config/sway/swaybar_info --netdev=enp7s0
# One can use the "--regex-cmd=<cmd>,<args...>,<regex>" option like so:
status_command $HOME/.config/sway/swaybar_info --regex-cmd="acpi,-b,[0-9]+%.*"
# One can use the "--regex-cmd=<cmd>[SPLIT]<args...>[SPLIT]<regex>" option like so:
status_command $HOME/.config/sway/swaybar_info --regex-cmd="acpi[SPLIT]-b[SPLIT][0-9]+%.*"
# This example gets battery info into the bar.
# Note that the <args...> portion is optional.
}

View file

@ -16,7 +16,7 @@ fn main() {
let mut cmds: Vec<(&str, Vec<&str>, regex::Regex)> = Vec::new();
for regex_cmd in &args_result.regex_cmds {
let mut split_strs = regex_cmd.split_terminator(',');
let mut split_strs = regex_cmd.split_terminator("[SPLIT]");
let cmd: &str = split_strs.next().expect("Should have cmd in option");
let mut args: Vec<&str> = Vec::new();
let mut next: Option<&str>;