diff --git a/.envrc b/.envrc deleted file mode 100644 index 4a4726a..0000000 --- a/.envrc +++ /dev/null @@ -1 +0,0 @@ -use_nix diff --git a/default.nix b/default.nix deleted file mode 100644 index 7c5ea65..0000000 --- a/default.nix +++ /dev/null @@ -1,19 +0,0 @@ -let - unstableTarball = fetchTarball - "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz"; - pkgs = import { }; - unstable = import unstableTarball { }; - -in with pkgs; -pkgs.mkShell { - name = "rust"; - buildInputs = [ - openssl - pkg-config - unstable.cargo - unstable.rustc - unstable.rustfmt - unstable.rust-analyzer - postgresql - ]; -} diff --git a/src/lib.rs b/src/lib.rs index 2d7e297..1ee348d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,8 +51,8 @@ pub struct Resolution { #[derive(Debug, Default)] pub struct Offset { - pub x: usize, - pub y: usize, + pub x: isize, + pub y: isize, } pub enum Orientation { @@ -106,16 +106,16 @@ impl Screen { None => return Err(CommandError::MissingMonitor(self.name.to_string())), }; - Ok(format!("{connection}: {w}x{h} @{in_w}x{in_h} +{x}+{y} {{ForceCompositionPipeline=On, ViewPortIn={in_w}x{in_h}, ViewPortOut={w}x{h}+0+0, Rotation={rotation}}}", - connection=connection, - w=width, - h=height, - in_w=in_w, - in_h=in_h, - x=x, - y=y, - rotation=rotation, - )) + Ok(format!("{connection}: {w}x{h} @{in_w}x{in_h} {x:+}{y:+} {{ForceCompositionPipeline=On, ViewPortIn={in_w}x{in_h}, ViewPortOut={w}x{h}+0+0, Rotation={rotation}}}", + connection=connection, + w=width, + h=height, + in_w=in_w, + in_h=in_h, + x=x, + y=y, + rotation=rotation, + )) } } @@ -167,6 +167,7 @@ mod tests { width: 1920, height: 1200, }, + offset: Offset { x: 0, y: 0 }, orientation: Orientation::Right, ..Default::default() }, @@ -201,14 +202,14 @@ mod tests { assert_eq!( build_cmd_args(&map, cfg).expect("failed build_cmd_args"), vec![ - "nvidia-settings", - "--assign", - "CurrentMetaMode=\ + "nvidia-settings", + "--assign", + "CurrentMetaMode=\ DFP-5.8: 1920x1200 @1200x1920 +0+0 {ForceCompositionPipeline=On, ViewPortIn=1200x1920, ViewPortOut=1920x1200+0+0, Rotation=270}, \ DFP-0.1: 3440x1440 @3440x1440 +1200+0 {ForceCompositionPipeline=On, ViewPortIn=3440x1440, ViewPortOut=3440x1440+0+0, Rotation=0}, \ DFP-0.8: 2560x1440 @2560x1440 +4640+0 {ForceCompositionPipeline=On, ViewPortIn=2560x1440, ViewPortOut=2560x1440+0+0, Rotation=0}" - ] + ] ); } diff --git a/src/main.rs b/src/main.rs index ca5ac40..7cfffa9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,36 +3,41 @@ use anyhow::Result; use fixscreen::*; fn main() -> Result<()> { + let dell = Screen { + name: ("DELL U2415".to_string()), + resolution: Resolution { + width: 1920, + height: 1200, + }, + offset: Offset { x: 0, y: 360 }, + ..Default::default() + }; + let lg = Screen { + name: ("LG Electronics 34UM95".to_string()), + resolution: Resolution { + width: 3440, + height: 1440, + }, + offset: Offset { + x: dell.resolution.width as isize, + y: 0, + }, + ..Default::default() + }; + let lenovo = Screen { + name: ("Lenovo Group Limited P27h-20".to_string()), + resolution: Resolution { + width: 2560, + height: 1440, + }, + offset: Offset { + x: (dell.resolution.width + lg.resolution.width) as isize, + y: 0, + }, + ..Default::default() + }; let cfg = Config { - screens: vec![ - Screen { - name: ("DELL U2415".to_string()), - resolution: Resolution { - width: 1920, - height: 1200, - }, - orientation: Orientation::Left, - ..Default::default() - }, - Screen { - name: ("LG Electronics 34UM95".to_string()), - resolution: Resolution { - width: 3440, - height: 1440, - }, - offset: Offset { x: 1200, y: 0 }, - ..Default::default() - }, - Screen { - name: ("Lenovo Group Limited P27h-20".to_string()), - resolution: Resolution { - width: 2560, - height: 1440, - }, - offset: Offset { x: 4640, y: 0 }, - ..Default::default() - }, - ], + screens: vec![dell, lg, lenovo], }; let map = screen_mapping_from_xorg_log("/var/log/X.0.log")?;