Initial randr plugin commit
This commit is contained in:
8
Cargo.lock
generated
8
Cargo.lock
generated
@@ -1430,6 +1430,14 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "randr"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"abi_stable",
|
||||||
|
"anyrun-plugin",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.2.16"
|
version = "0.2.16"
|
||||||
|
@@ -8,4 +8,5 @@ members = [
|
|||||||
"plugins/rink",
|
"plugins/rink",
|
||||||
"plugins/shell",
|
"plugins/shell",
|
||||||
"plugins/translate",
|
"plugins/translate",
|
||||||
|
"plugins/randr",
|
||||||
]
|
]
|
13
plugins/randr/Cargo.toml
Normal file
13
plugins/randr/Cargo.toml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
[package]
|
||||||
|
name = "randr"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
abi_stable = "0.11.1"
|
||||||
|
anyrun-plugin = { path = "../../anyrun-plugin" }
|
6
plugins/randr/src/lib.rs
Normal file
6
plugins/randr/src/lib.rs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
use randr::Randr;
|
||||||
|
|
||||||
|
mod randr;
|
||||||
|
mod wlr_randr;
|
||||||
|
|
||||||
|
fn init() -> Box<dyn Randr> {}
|
20
plugins/randr/src/randr.rs
Normal file
20
plugins/randr/src/randr.rs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
pub struct Mode {
|
||||||
|
width: u32,
|
||||||
|
height: u32,
|
||||||
|
rate: f64,
|
||||||
|
preferred: bool,
|
||||||
|
current: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Monitor {
|
||||||
|
output: String,
|
||||||
|
modes: Vec<Mode>,
|
||||||
|
x: i32,
|
||||||
|
y: i32,
|
||||||
|
enabled: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait Randr {
|
||||||
|
fn get_monitors(&self) -> Vec<Monitor>;
|
||||||
|
fn set_mode(&self, mon: &Monitor, mode: &Mode) -> Result<(), String>;
|
||||||
|
}
|
24
plugins/randr/src/wlr_randr.rs
Normal file
24
plugins/randr/src/wlr_randr.rs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
use std::process::Command;
|
||||||
|
|
||||||
|
use crate::randr::{Mode, Monitor, Randr};
|
||||||
|
|
||||||
|
pub struct WlrRandr {
|
||||||
|
pub exec: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WlrRandr {
|
||||||
|
fn run_wlr_randr(&self, args: &[&str]) -> String {
|
||||||
|
String::from_utf8(Command::new(self.exec).args(args).output().unwrap().stdout).unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Randr for WlrRandr {
|
||||||
|
fn get_monitors(&self) -> Vec<Monitor> {
|
||||||
|
let output = self.run_wlr_randr(&[]);
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_mode(&self, mon: &Monitor, mode: &Mode) -> Result<(), String> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user