mirror of
https://gitlab.com/hyask/swaysome.git
synced 2025-12-10 07:44:43 +01:00
Turn 'get_outputs' into 'get_active_outputs'
This commit is contained in:
parent
9200db526a
commit
1a450b0191
1 changed files with 6 additions and 5 deletions
11
src/main.rs
11
src/main.rs
|
|
@ -100,13 +100,14 @@ fn check_success(stream: &UnixStream) {
|
|||
};
|
||||
}
|
||||
|
||||
fn get_outputs(stream: &UnixStream) -> Vec<serde_json::Value> {
|
||||
fn get_active_outputs(stream: &UnixStream) -> Vec<serde_json::Value> {
|
||||
send_msg(&stream, GET_OUTPUTS, "");
|
||||
let o = match read_msg(&stream) {
|
||||
Ok(msg) => msg,
|
||||
Err(_) => panic!("Unable to get outputs"),
|
||||
};
|
||||
serde_json::from_str(&o).unwrap()
|
||||
let outputs: Vec<serde_json::Value> = serde_json::from_str(&o).unwrap();
|
||||
outputs.into_iter().filter(|x| x["active"] == serde_json::Value::Bool(true)).collect()
|
||||
}
|
||||
|
||||
fn get_workspaces(stream: &UnixStream) -> Vec<serde_json::Value> {
|
||||
|
|
@ -119,7 +120,7 @@ fn get_workspaces(stream: &UnixStream) -> Vec<serde_json::Value> {
|
|||
}
|
||||
|
||||
fn get_current_output_name(stream: &UnixStream) -> String {
|
||||
let outputs = get_outputs(&stream);
|
||||
let outputs = get_active_outputs(&stream);
|
||||
|
||||
let focused_output_index = match outputs.iter().position(|x| x["focused"] == serde_json::Value::Bool(true)) {
|
||||
Some(i) => i,
|
||||
|
|
@ -158,7 +159,7 @@ fn move_container_to_prev_output(stream: &UnixStream) {
|
|||
}
|
||||
|
||||
fn move_container_to_next_or_prev_output(stream: &UnixStream, go_to_prev: bool) {
|
||||
let outputs = get_outputs(&stream);
|
||||
let outputs = get_active_outputs(&stream);
|
||||
let focused_output_index = match outputs.iter().position(|x| x["focused"] == serde_json::Value::Bool(true)) {
|
||||
Some(i) => i,
|
||||
None => panic!("WTF! No focused output???"),
|
||||
|
|
@ -190,7 +191,7 @@ fn move_container_to_next_or_prev_output(stream: &UnixStream, go_to_prev: bool)
|
|||
}
|
||||
|
||||
fn init_workspaces(stream: &UnixStream) {
|
||||
let outputs = get_outputs(&stream);
|
||||
let outputs = get_active_outputs(&stream);
|
||||
|
||||
let cmd_prefix: String = "focus output ".to_string();
|
||||
for output in outputs.iter().rev() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue