minor stuff
This commit is contained in:
parent
21df59e00b
commit
876c08e923
32
src/main.rs
32
src/main.rs
@ -18,7 +18,7 @@ struct Globals {
|
|||||||
status_manager: Option<Main<ZriverStatusManagerV1>>,
|
status_manager: Option<Main<ZriverStatusManagerV1>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Config {
|
struct Status {
|
||||||
seat_name: String,
|
seat_name: String,
|
||||||
keypair: Vec<Keypair>,
|
keypair: Vec<Keypair>,
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ impl Keypair {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Status {
|
||||||
fn mod_value(&mut self, key: String, value: String) {
|
fn mod_value(&mut self, key: String, value: String) {
|
||||||
for keypair in &mut self.keypair {
|
for keypair in &mut self.keypair {
|
||||||
if keypair.key.eq(&key) { keypair.value = value; break }
|
if keypair.key.eq(&key) { keypair.value = value; break }
|
||||||
@ -73,7 +73,7 @@ fn main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut args = std::env::args();
|
let mut args = std::env::args();
|
||||||
let mut config = { Config {
|
let mut status = { Status {
|
||||||
seat_name: String::new(),
|
seat_name: String::new(),
|
||||||
keypair: Vec::new()
|
keypair: Vec::new()
|
||||||
} };
|
} };
|
||||||
@ -85,7 +85,7 @@ fn main() {
|
|||||||
loop {
|
loop {
|
||||||
match args.next() {
|
match args.next() {
|
||||||
Some(flag) => match flag.as_str() {
|
Some(flag) => match flag.as_str() {
|
||||||
"--seat" | "-s" => config.seat_name = args.next().unwrap_or(String::new()),
|
"--seat" | "-s" => status.seat_name = args.next().unwrap_or(String::new()),
|
||||||
"--monitor" | "-m" => {
|
"--monitor" | "-m" => {
|
||||||
monitor = match args.next().unwrap_or(String::new()).parse::<usize>() {
|
monitor = match args.next().unwrap_or(String::new()).parse::<usize>() {
|
||||||
Ok(i) => Some(i),
|
Ok(i) => Some(i),
|
||||||
@ -151,14 +151,14 @@ fn main() {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.expect("Compositor doesn't implement river_status_unstable_v1")
|
.expect("Compositor doesn't implement river_status_unstable_v1")
|
||||||
.get_river_seat_status(&seat);
|
.get_river_seat_status(&seat);
|
||||||
config.add_keypair("title".to_owned());
|
status.add_keypair("title".to_owned());
|
||||||
seat.quick_assign(move |_, event, mut config| {
|
seat.quick_assign(move |_, event, mut status| {
|
||||||
let seat_name = &config.get::<Config>().unwrap().seat_name;
|
let seat_name = &status.get::<Status>().unwrap().seat_name;
|
||||||
match event {
|
match event {
|
||||||
wl_seat::Event::Name{ name } => if seat_name.len() == 0 || name.eq(seat_name) {
|
wl_seat::Event::Name{ name } => if seat_name.len() == 0 || name.eq(seat_name) {
|
||||||
seat_status.quick_assign(move |_, event, mut config| match event {
|
seat_status.quick_assign(move |_, event, mut status| match event {
|
||||||
zriver_seat_status_v1::Event::FocusedView { title } => {
|
zriver_seat_status_v1::Event::FocusedView { title } => {
|
||||||
config.get::<Config>().unwrap().mod_value("title".to_owned(), title);
|
status.get::<Status>().unwrap().mod_value("title".to_owned(), title);
|
||||||
},
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
})
|
})
|
||||||
@ -177,17 +177,17 @@ fn main() {
|
|||||||
if *i == index { true } else { false }
|
if *i == index { true } else { false }
|
||||||
} else { true })
|
} else { true })
|
||||||
{
|
{
|
||||||
if enable_tag { config.add_keypair(format!("tag{}",i)); }
|
if enable_tag { status.add_keypair(format!("tag{}",i)); }
|
||||||
if enable_views_tag { config.add_keypair(format!("views_tag{}",i)); }
|
if enable_views_tag { status.add_keypair(format!("views_tag{}",i)); }
|
||||||
let output_status = globals
|
let output_status = globals
|
||||||
.status_manager
|
.status_manager
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.expect("Compositor doesn't implement river_status_unstable_v1")
|
.expect("Compositor doesn't implement river_status_unstable_v1")
|
||||||
.get_river_output_status(&output);
|
.get_river_output_status(&output);
|
||||||
output_status.quick_assign(move |_, event, mut config| match event {
|
output_status.quick_assign(move |_, event, mut status| match event {
|
||||||
zriver_output_status_v1::Event::FocusedTags { tags } => {
|
zriver_output_status_v1::Event::FocusedTags { tags } => {
|
||||||
if enable_tag {
|
if enable_tag {
|
||||||
config.get::<Config>().unwrap().mod_value(format!("tag{}",i), base10(tags).trim_end().to_owned());
|
status.get::<Status>().unwrap().mod_value(format!("tag{}",i), base10(tags).trim_end().to_owned());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
zriver_output_status_v1::Event::ViewTags { tags } => {
|
zriver_output_status_v1::Event::ViewTags { tags } => {
|
||||||
@ -198,7 +198,7 @@ fn main() {
|
|||||||
let buf: [u8; 4] = [tags[i], tags[i + 1], tags[i + 2], tags[i + 3]];
|
let buf: [u8; 4] = [tags[i], tags[i + 1], tags[i + 2], tags[i + 3]];
|
||||||
views_tag.push_str(&base10(u32::from_le_bytes(buf)));
|
views_tag.push_str(&base10(u32::from_le_bytes(buf)));
|
||||||
}
|
}
|
||||||
config.get::<Config>().unwrap().mod_value(format!("views_tag{}",i), views_tag.trim_end().to_owned());
|
status.get::<Status>().unwrap().mod_value(format!("views_tag{}",i), views_tag.trim_end().to_owned());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -207,7 +207,7 @@ fn main() {
|
|||||||
|
|
||||||
loop {
|
loop {
|
||||||
event_queue
|
event_queue
|
||||||
.dispatch(&mut config, |event, object, _| {
|
.dispatch(&mut status, |event, object, _| {
|
||||||
panic!(
|
panic!(
|
||||||
"[callop] Encountered an orphan event: {}@{}: {}",
|
"[callop] Encountered an orphan event: {}@{}: {}",
|
||||||
event.interface,
|
event.interface,
|
||||||
@ -216,7 +216,7 @@ fn main() {
|
|||||||
);
|
);
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
config.to_string()
|
status.to_string()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user