From d29fabb04465f0215ab010babbef16918e240df0 Mon Sep 17 00:00:00 2001 From: LordGrimmauld Date: Thu, 11 Apr 2024 10:56:21 +0200 Subject: [PATCH] abstract screenshare selection --- common/portals.nix | 9 +++++ common/sway.nix | 6 ++++ load_common.nix | 34 +++++++++++++++++++ specific/grimm-nixos-laptop/configuration.nix | 1 - .../hardware-configuration.nix | 12 +++++++ .../grimm-nixos-laptop/screenshare-select.nix | 17 ---------- sway/sway-conf.nix | 4 +-- 7 files changed, 63 insertions(+), 20 deletions(-) delete mode 100644 specific/grimm-nixos-laptop/screenshare-select.nix diff --git a/common/portals.nix b/common/portals.nix index 7813d2b..413effe 100644 --- a/common/portals.nix +++ b/common/portals.nix @@ -12,6 +12,15 @@ in xdg-desktop-portal-kde xdg-desktop-portal-gtk ]; + + wlr.settings = lib.mapAttrs' + (name: value: lib.nameValuePair ("screencast_" + name) { + output_name = value.id; + max_fps = value.fps; + chooser_type = "simple"; + chooser_cmd = "${pkgs.slurp}/bin/slurp -f %o -or"; + }) + cfg.screens; }; environment.sessionVariables = { diff --git a/common/sway.nix b/common/sway.nix index 17cd445..ba22d56 100644 --- a/common/sway.nix +++ b/common/sway.nix @@ -37,6 +37,12 @@ in text = lib.strings.concatLines ( (build_conf cfg.sway.config) ++ lib.optional cfg.sway.bar.enable bar_config + ++ (lib.mapAttrsToList + (name: value: + "output ${value.id} mode ${value.mode}@${toString value.fps}Hz" + + (lib.optionalString (value.pos != null) " position ${value.pos}") + ) + cfg.screens) ); sway_conf = pkgs.writeText "sway.conf" text; diff --git a/load_common.nix b/load_common.nix index 69a1077..91169f5 100644 --- a/load_common.nix +++ b/load_common.nix @@ -17,6 +17,34 @@ let }; }); + screen = types.submodule { + options = { + fps = mkOption { + type = types.int; + default = 60; + description = "max framerate of screen"; + }; + + mode = mkOption { + type = types.nonEmptyStr; + default = "1920x1080"; + description = "pixel format of the screen"; + }; + + id = mkOption { + type = types.nonEmptyStr; + description = "ID of the screen"; + }; + + pos = mkOption { + type = types.nullOr types.nonEmptyStr; + default = null; + example = "0,0"; + description = "position where to place the screen"; + }; + }; + }; + sway_conf = types.submodule ({ config, ... }: rec { options = { keybinds = mkOption { @@ -135,6 +163,12 @@ in }; }; + screens = mkOption { + type = types.attrsOf screen; + default = { }; + description = "Screens to initialize"; + }; + sway = { enable = mkEnableOption "grimm-sway"; diff --git a/specific/grimm-nixos-laptop/configuration.nix b/specific/grimm-nixos-laptop/configuration.nix index 877864c..1be5f1b 100644 --- a/specific/grimm-nixos-laptop/configuration.nix +++ b/specific/grimm-nixos-laptop/configuration.nix @@ -2,7 +2,6 @@ imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix - ./screenshare-select.nix ]; age.identityPaths = [ "/home/grimmauld/.ssh/id_rsa" ]; diff --git a/specific/grimm-nixos-laptop/hardware-configuration.nix b/specific/grimm-nixos-laptop/hardware-configuration.nix index 67c059d..81cd689 100644 --- a/specific/grimm-nixos-laptop/hardware-configuration.nix +++ b/specific/grimm-nixos-laptop/hardware-configuration.nix @@ -32,6 +32,18 @@ size = 48 * 1024; }]; + grimmShared.screens = { + external = { + id = "HDMI-A-1"; + pos = "0,0"; + }; + + internal = { + id = "eDP-1"; + fps = 144; + }; + }; + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; powerManagement.cpuFreqGovernor = lib.mkDefault "performance"; hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; diff --git a/specific/grimm-nixos-laptop/screenshare-select.nix b/specific/grimm-nixos-laptop/screenshare-select.nix deleted file mode 100644 index 0827869..0000000 --- a/specific/grimm-nixos-laptop/screenshare-select.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ pkgs, ... }: -{ - xdg.portal.wlr.settings = { - screencastExternal = { - output_name = "HDMI-A-1"; - max_fps = 60; - chooser_type = "simple"; - chooser_cmd = "${pkgs.slurp}/bin/slurp -f %o -or"; - }; - screencastInternal = { - output_name = "eDP-1"; - max_fps = 144; - chooser_type = "simple"; - chooser_cmd = "${pkgs.slurp}/bin/slurp -f %o -or"; - }; - }; -} diff --git a/sway/sway-conf.nix b/sway/sway-conf.nix index 88a4304..db75136 100644 --- a/sway/sway-conf.nix +++ b/sway/sway-conf.nix @@ -148,8 +148,7 @@ ]; extraConfig = '' output * bg ${./wallpapers/switzerland.jpg} fill - output HDMI-A-1 mode 1920x1080@60Hz position 0,0 - for_window [app_id="lxqt-policykit-agent"] floating enable; + floating_modifier $mod normal input type:keyboard xkb_numlock enabled @@ -172,6 +171,7 @@ for_window [app_id="swaymux"] floating enable for_window [app_id="rmenu"] floating enable + for_window [app_id="lxqt-policykit-agent"] floating enable; ''; modes.resize.keybinds = {