diff options
| -rw-r--r-- | home/apps/default.nix | 1 | ||||
| -rw-r--r-- | home/apps/kanshi.nix | 53 | ||||
| -rw-r--r-- | hosts/shinji/default.nix | 2 | ||||
| -rw-r--r-- | options.nix | 6 |
4 files changed, 62 insertions, 0 deletions
diff --git a/home/apps/default.nix b/home/apps/default.nix index 1823b0d..baf9d82 100644 --- a/home/apps/default.nix +++ b/home/apps/default.nix @@ -7,6 +7,7 @@ _: { ./alacritty.nix ./astal.nix ./hyprlock.nix + ./kanshi.nix ./kitty.nix ./mako.nix ]; diff --git a/home/apps/kanshi.nix b/home/apps/kanshi.nix new file mode 100644 index 0000000..ed7622a --- /dev/null +++ b/home/apps/kanshi.nix @@ -0,0 +1,53 @@ +{ + config, + lib, + ... +}: let + inherit (lib) mkIf; + cfg = config.apps.kanshi; + + laptopMonitors = lib.lists.filter (mon: mon.laptop) config.monitors; + dockedMonitors = lib.lists.filter (mon: !mon.laptop) config.monitors; + + mkOutput = mon: status: + lib.mkMerge [ + { + criteria = + if mon.desc == "" + then mon.port + else mon.desc; + scale = mon.scale; + inherit status; + } + (lib.mkIf (mon.position.x != 0 || mon.position.y != 0) { + position = "${toString mon.position.x},${toString mon.position.y}"; + }) + (lib.mkIf (mon.size.x != 0 && mon.size.y != 0) { + mode = "${toString mon.size.x}x${toString mon.size.y}"; + }) + ]; + + mkEnabledOutput = mon: (mkOutput mon "enable"); + mkDisabledOutput = mon: (mkOutput mon "disable"); +in { + config = mkIf cfg.enable { + services.kanshi = { + enable = true; + + settings = [ + { + profile = { + name = "laptop"; + outputs = map mkEnabledOutput laptopMonitors; + }; + } + { + profile = { + name = "docked"; + outputs = (map mkEnabledOutput dockedMonitors) ++ (map mkDisabledOutput laptopMonitors); + }; + } + ]; + }; + }; +} diff --git a/hosts/shinji/default.nix b/hosts/shinji/default.nix index ec86418..d220725 100644 --- a/hosts/shinji/default.nix +++ b/hosts/shinji/default.nix @@ -17,6 +17,7 @@ monitors = [ { port = "eDP-1"; + laptop = true; scale = 1.25; bitdepth = 10; } @@ -70,6 +71,7 @@ caelestia.enable = true; hyprlock.enable = true; rofi.enable = true; + kanshi.enable = true; kitty.enable = true; }; browsers = { diff --git a/options.nix b/options.nix index c80cdfd..241f726 100644 --- a/options.nix +++ b/options.nix @@ -19,6 +19,11 @@ with lib; let default = ""; }; + laptop = mkEnableOption { + description = "Flags this monitor to be part of a laptop and not docked."; + default = false; + }; + position = { enabled = mkEnableOption { description = "Enables hardcoded position of the monitor."; @@ -473,6 +478,7 @@ in { apps = { alacritty.enable = mkEnableOption "Enable the alacritty terminal."; astal.enable = mkEnableOption "Enable the astal gtk shell."; + kanshi.enable = mkEnableOption "Enable the kanshi service."; kitty.enable = mkEnableOption "Enable the kitty terminal."; mako.enable = mkEnableOption "Enable the mako notification daemon."; hyprlock.enable = mkEnableOption "Enable the hyprlock lockscreen."; |