Make a nice common monitor database

This commit is contained in:
Natsu Kagami 2023-08-31 13:24:39 +02:00
parent 4d1144e84b
commit 8860ed52da
Signed by: nki
GPG key ID: 55A032EB38B49ADB
5 changed files with 75 additions and 24 deletions

View file

@ -1,6 +1,7 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; { with lib; {
imports = [ imports = [
./modules/monitors.nix
./modules/linux/graphical ./modules/linux/graphical
./modules/X11/xfce4-notifyd.nix ./modules/X11/xfce4-notifyd.nix
./modules/programs/discord.nix ./modules/programs/discord.nix

View file

@ -48,32 +48,22 @@
top_x = builtins.ceil (3840 / scale); top_x = builtins.ceil (3840 / scale);
top_y = builtins.ceil (((2160 / scale) - 1080) / 2); top_y = builtins.ceil (((2160 / scale) - 1080) / 2);
in in
{ with config.common.monitors; {
"AOC U28G2G6B PPYP2JA000013" = { ${home_4k.name} = {
mode = "3840x2160@60Hz";
scale = toString scale; scale = toString scale;
adaptive_sync = "on";
# render_bit_depth = "10";
position = "0 0"; position = "0 0";
}; };
"AOC 24G2W1G4 ATNN21A005410" = { ${home_1080.name} = {
mode = "1920x1080@144Hz";
adaptive_sync = "on";
position = "${toString top_x} ${toString top_y}"; position = "${toString top_x} ${toString top_y}";
}; };
"ViewSonic Corporation XG2402 SERIES V4K182501054" = {
mode = "1920x1080@144Hz";
adaptive_sync = "on";
};
}; };
nki.programs.kitty.enable = true; nki.programs.kitty.enable = true;
nki.programs.kitty.fontSize = 14; nki.programs.kitty.fontSize = 14;
programs.my-sway.waybar.makeBars = barWith: [ programs.my-sway.waybar.makeBars = with config.common.monitors; barWith: [
# For primary # For primary
(barWith { extraSettings = { output = [ "AOC U28G2G6B PPYP2JA000013" ]; }; }) (barWith { extraSettings = { output = [ home_4k.name ]; }; })
# For secondary, hide mpd # For secondary, hide mpd
(barWith { showMedia = false; showConnectivity = false; extraSettings = { output = [ "AOC 24G2W1G4 ATNN21A005410" ]; }; }) (barWith { showMedia = false; showConnectivity = false; extraSettings = { output = [ home_1080.name ]; }; })
]; ];
# Yellow light! # Yellow light!

50
home/modules/monitors.nix Normal file
View file

@ -0,0 +1,50 @@
# A monitor list and common sway set up
{ config, pkgs, lib, ... }: with lib;
let
monitors = {
# Internal
# External
## Work @ EPFL
"work" = {
name = "LG Electronics LG ULTRAFINE 301MAXSGHD10";
mode = "3840x2160@60Hz";
scale = "1.25";
};
"home_4k" = {
name = "AOC U28G2G6B PPYP2JA000013";
mode = "3840x2160@60Hz";
scale = mkDefault "1.5";
adaptive_sync = "on";
# render_bit_depth = "10";
};
"home_1080" = {
name = "AOC 24G2W1G4 ATNN21A005410";
mode = "1920x1080@144Hz";
adaptive_sync = "on";
};
"viewsonic_1080" = {
name = "ViewSonic Corporation XG2402 SERIES V4K182501054";
mode = "1920x1080@144Hz";
adaptive_sync = "on";
};
};
eachMonitor = _name: monitor: {
name = monitor.name;
value = builtins.removeAttrs monitor [ "name" ];
};
in
{
options.common.monitors = mkOption {
type = types.attrsOf types.attrs;
description = "A list of monitors";
};
config.common.monitors = monitors;
config.home.packages = mkIf config.wayland.windowManager.sway.enable (with pkgs; [ kanshi ]);
config.wayland.windowManager.sway.config.output = mkIf config.wayland.windowManager.sway.enable (
mapAttrs' eachMonitor monitors
);
}

View file

@ -82,14 +82,18 @@
}; };
# Multiple screen setup # Multiple screen setup
# services.kanshi = { services.kanshi = {
# enable = true; enable = true;
# profiles.undocked.outputs = [{ criteria = "LVDS-1"; }]; profiles.undocked.outputs = [{ criteria = "LVDS-1"; }];
# profiles.docked-hdmi.outputs = [ profiles.work-both.outputs = [
# # { criteria = "LVDS-1"; status = "disable"; } { criteria = "eDP-1"; position = "0,0"; status = "enable"; }
# { criteria = "HDMI-A-1"; } { criteria = config.common.monitors.work.name; position = "1920,0"; }
# ]; ];
# }; profiles.work-one.outputs = [
{ criteria = "eDP-1"; status = "disable"; }
{ criteria = config.common.monitors.work.name; }
];
};
# This value determines the Home Manager release that your # This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage # configuration is compatible with. This helps avoid breakage

View file

@ -17,6 +17,12 @@ let
if builtins.compareVersions prev.sublime-music.version "0.12" < 0 if builtins.compareVersions prev.sublime-music.version "0.12" < 0
then final.unstable.sublime-music then final.unstable.sublime-music
else prev.sublime-music; else prev.sublime-music;
# New stuff in Kanshi 1.4.0
kanshi =
if builtins.compareVersions prev.kanshi.version "1.4.0" < 0
then final.callPackage final.unstable.kanshi.override { }
else prev.kanshi;
}; };
overlay-imported = final: prev: { overlay-imported = final: prev: {
rnix-lsp = inputs.rnix-lsp.defaultPackage."${final.system}"; rnix-lsp = inputs.rnix-lsp.defaultPackage."${final.system}";