From 2c8aeb0ce661b11e193a379340eda667cbf948bf Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Sat, 22 Oct 2022 15:01:11 +0200 Subject: [PATCH] multi monitor setup with autorandr --- flake.lock | 19 +++++++++++- flake.nix | 6 +++- nixos/machines/sterni/packages.nix | 2 ++ nixos/system/desktop/home-manager/i3.nix | 38 ++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 2 deletions(-) diff --git a/flake.lock b/flake.lock index 8e88eb2..7aaf346 100644 --- a/flake.lock +++ b/flake.lock @@ -845,7 +845,8 @@ "private_assets": "private_assets", "retiolum": "retiolum", "secrets": "secrets", - "sops-nix": "sops-nix" + "sops-nix": "sops-nix", + "thinkpad-dock": "thinkpad-dock" } }, "rotate-text": { @@ -949,6 +950,22 @@ "type": "github" } }, + "thinkpad-dock": { + "flake": false, + "locked": { + "lastModified": 1617280004, + "narHash": "sha256-nhmYoiHNHk64CjgG7dutVpmrWpdwE3+4G8fGWNANTi8=", + "owner": "oxzi", + "repo": "nixos-thinkpad-dock", + "rev": "c18fe4116b20886c112acec19294e9b96e919526", + "type": "github" + }, + "original": { + "owner": "oxzi", + "repo": "nixos-thinkpad-dock", + "type": "github" + } + }, "ts-fold": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index 3c73a7d..880b6d0 100644 --- a/flake.nix +++ b/flake.nix @@ -59,7 +59,10 @@ url = "github:krebs/retiolum"; flake = false; }; - + thinkpad-dock = { + url = "github:oxzi/nixos-thinkpad-dock"; + flake = false; + }; }; outputs = @@ -80,6 +83,7 @@ , secrets , sops-nix , retiolum + , thinkpad-dock }: let system = "x86_64-linux"; diff --git a/nixos/machines/sterni/packages.nix b/nixos/machines/sterni/packages.nix index db82d57..fd054d4 100644 --- a/nixos/machines/sterni/packages.nix +++ b/nixos/machines/sterni/packages.nix @@ -26,6 +26,8 @@ in }; })) + autorandr + (nextcloudSync "InstantUpload") (nextcloudSync "Pictures") (nextcloudSync "Unterlagen") diff --git a/nixos/system/desktop/home-manager/i3.nix b/nixos/system/desktop/home-manager/i3.nix index 376b7e1..728c7f8 100644 --- a/nixos/system/desktop/home-manager/i3.nix +++ b/nixos/system/desktop/home-manager/i3.nix @@ -268,6 +268,44 @@ in "${cfg.config.modifier}+r" = "mode resize"; + # multiple monitors + # autorandr --save docked # to save setup + # autorandr --save undocked # to save setup + # autorandr --change # automatically detects the setup + "${cfg.config.modifier}+BackSpace" = + let + xmodmapConfig = pkgs.writeText "xmodmap" '' + ! + ! Swap Caps_Lock and Control_L + ! + + ! replace capslock keys with Escape Keys + ! remove Lock = Caps_Lock + clear Lock + add Lock = Scroll_Lock + + keysym Caps_Lock = Escape + + ! Set Right function Key to Windows-key + keycode 135 = Super_R NoSymbol Super_R NoSymbol Super_R + + ! Map umlauts to RIGHT ALT + + keycode 108 = Mode_switch + keysym e = e E EuroSign + keysym c = c C cent + keysym a = a A adiaeresis Adiaeresis + keysym o = o O odiaeresis Odiaeresis + keysym u = u U udiaeresis Udiaeresis + keysym s = s S ssharp + ''; + script = pkgs.writers.writeBash "autorandr" '' + ${pkgs.autorandr}/bin/autorandr --change + ${pkgs.xorg.xmodmap}/bin/xmodmap ${xmodmapConfig} + ${backgroundCommand} + ''; + in + "exec ${toString script}"; + # like vimperator "${cfg.config.modifier}+a" = "exec ${pkgs.i3-easyfocus}/bin/i3-easyfocus";