Check for screen number

This commit is contained in:
Nabos 2022-08-05 12:56:00 +02:00
parent b39b51ad58
commit 6fe7ca7bc3

View file

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