Skip to content

Commit

Permalink
feat: add the output -o
Browse files Browse the repository at this point in the history
  • Loading branch information
Decodetalkers committed Dec 19, 2023
1 parent 44889dc commit cbf9c45
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
17 changes: 17 additions & 0 deletions libwaysip/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ impl ZXdgOutputInfo {
fn get_screen_info(&self, output: WlOutput) -> ScreenInfo {
ScreenInfo {
output,
start_x: self.start_x,
start_y: self.start_y,
width: self.width,
height: self.height,
name: self.name.clone(),
Expand All @@ -100,25 +102,40 @@ impl ZXdgOutputInfo {
#[derive(Debug)]
pub struct ScreenInfo {
output: WlOutput,
start_x: i32,
start_y: i32,
width: i32,
height: i32,
name: String,
description: String,
}

impl ScreenInfo {

/// get the binding output
pub fn get_output(&self) -> &WlOutput {
&self.output
}

/// get the logical size of the screen
pub fn get_size(&self) -> (i32, i32) {
(self.width, self.height)
}

/// get the name of the screen
pub fn get_name(&self) -> &str {
&self.name
}

/// get the description of the screen
pub fn get_description(&self) -> &str {
&self.description
}

/// get the logical positon of the screen
pub fn get_position(&self) -> (i32, i32) {
(self.start_x, self.start_y)
}
}

#[derive(Debug)]
Expand Down
9 changes: 9 additions & 0 deletions waysip/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ enum Cli {
Dimesions,
#[command(short_flag = 's')]
Screen,
#[command(short_flag = 'o')]
Output,
}

fn main() {
Expand Down Expand Up @@ -54,5 +56,12 @@ fn main() {
println!("Screen : {name} {description}");
println!("width: {w}, height: {h}");
}
Cli::Output => {
let info = get_info!(WaySipKind::Screen);
let screen_info = info.selected_screen_info();
let (x, y) = screen_info.get_position();
let (width, height) = screen_info.get_size();
println!("{x},{y} {width}x{height}",);
}
}
}

0 comments on commit cbf9c45

Please sign in to comment.