diff --git a/src/lib.rs b/src/lib.rs index 9dd1512..7cf4ba3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,6 +14,7 @@ use xrandr::{XHandle, XrandrError}; pub fn swap_workspaces(cfg: &Config) -> Result>, CommandError> { let monitors = XHandle::open()?.monitors()?; + dbg!(&monitors); // TODO(wathiede): if I ever get two monitors with the same resolution, use EDID to find a // better key. let map: HashMap<_, _> = monitors diff --git a/src/main.rs b/src/main.rs index 87ab8ab..64043c4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,23 +23,6 @@ fn main() -> Result<()> { workspaces: vec!["virtue".to_string()], ..Default::default() }; - let lg = Screen { - name: ("LG Electronics 34UM95".to_string()), - resolution: Resolution { - width: 3440, - height: 1440, - }, - offset: Offset { - // The '1 +' here creates a gap between the top monitor and side monitor. When all - // monitors have a gap, you can move the mouse between any combo. When the top monitor - // is flush with the left, the bottom monitor will have a hard edge that prevents the - // mouse from moving to the left monitor. - x: 1 + dell24.resolution.height as isize, - y: 0, - }, - workspaces: vec!["twilight".to_string()], - ..Default::default() - }; let lenovo = Screen { name: ("Lenovo Group Limited P27h-20".to_string()), resolution: Resolution { @@ -51,12 +34,35 @@ fn main() -> Result<()> { workspaces: vec!["fraud".to_string()], ..Default::default() }; - let screens = vec![dell24, dell30, lenovo]; + let lg = Screen { + name: ("LG Electronics 34UM95".to_string()), + resolution: Resolution { + width: 3440, + height: 1440, + }, + offset: Offset { + // The '1 +' here creates a gap between the top monitor and side monitor. When all + // monitors have a gap, you can move the mouse between any combo. When the top monitor + // is flush with the left, the bottom monitor will have a hard edge that prevents the + // mouse from moving to the left monitor. + x: (1 + dell24.resolution.width + dell30.resolution.width.max(lenovo.resolution.width)) + as isize, + y: ((dell30.resolution.height + lenovo.resolution.height) / 2 - 1440 / 2) as isize, + }, + workspaces: vec!["twilight".to_string()], + ..Default::default() + }; + let map = screen_mapping_from_xorg_log("/var/log/X.0.log")?; + let lg_connected = std::env::args().len() > 1; + + let mut screens = vec![dell24, dell30, lenovo]; + if lg_connected { + screens.push(lg); + } let cfg = Config { screens: screens.clone(), }; - let map = screen_mapping_from_xorg_log("/var/log/X.0.log")?; let cmd = run_cmd(&map, &cfg)?; println!("cmd {:#?}", cmd); // TODO(wathiede): run xrandr --output $DPY --primary