diff --git a/src/main.rs b/src/main.rs index 90510b5..1c2c75d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,7 +24,7 @@ const GET_OUTPUTS: u32 = 3; #[clap(propagate_version = true)] struct Cli { #[clap(subcommand)] - command: Command + command: Command, } #[derive(Subcommand, Debug)] @@ -54,19 +54,19 @@ enum Command { #[derive(Args, Debug)] struct InitAction { #[clap(value_name = "index", help = "The index to initialize with")] - name: String + name: String, } #[derive(Args, Debug)] struct FocusAction { #[clap(value_name = "index", help = "The index to focus on")] - name: String + name: String, } #[derive(Args, Debug)] struct MoveAction { #[clap(value_name = "index", help = "The index to move the container to")] - name: String + name: String, } fn get_stream() -> UnixStream { @@ -313,9 +313,11 @@ fn rearrange_workspaces(stream: &UnixStream) { send_command(stream, &focus_cmd); let output_index = (workspace.num / 10) as usize; - let mut move_cmd = move_cmd_prefix.clone(); - move_cmd.push_str(&outputs[output_index].name); - send_command(stream, &move_cmd); + if output_index < outputs.len() { + let mut move_cmd = move_cmd_prefix.clone(); + move_cmd.push_str(&outputs[output_index].name); + send_command(stream, &move_cmd); + } } }