From 4ec33c26d4d1c86524006bcd3948a1ca9564ed4e Mon Sep 17 00:00:00 2001 From: Mat Jones Date: Sun, 29 Sep 2024 11:41:40 -0400 Subject: [PATCH] feat(gnome): Declaratively set monitor config --- conf.d/gnome-monitors.xml | 71 ++++++++++++++++++++++++++ home-manager/modules/gnome/default.nix | 59 +++++++++++---------- nixos-modules/desktop_environment.nix | 10 +++- 3 files changed, 111 insertions(+), 29 deletions(-) create mode 100644 conf.d/gnome-monitors.xml diff --git a/conf.d/gnome-monitors.xml b/conf.d/gnome-monitors.xml new file mode 100644 index 00000000..92320b92 --- /dev/null +++ b/conf.d/gnome-monitors.xml @@ -0,0 +1,71 @@ + + + + 0 + 1440 + 1 + yes + + + DP-2 + GSM + LG ULTRAWIDE + 207NTYT1A970 + + + 5120 + 1440 + 143.979 + + + + + 5120 + 320 + 1 + + left + no + + + + HDMI-0 + VSC + VX2478 Series + UPN172200089 + + + 2560 + 1440 + 59.951 + + + + + 1680 + 0 + 1 + + + HDMI-1 + SPT + Sceptre C35 + 0000000000000 + + + 3440 + 1440 + 59.999 + + + + + + DP-1 + SAM + SAMSUNG + 0x01000e00 + + + + diff --git a/home-manager/modules/gnome/default.nix b/home-manager/modules/gnome/default.nix index 67e38521..f46da2d4 100644 --- a/home-manager/modules/gnome/default.nix +++ b/home-manager/modules/gnome/default.nix @@ -1,32 +1,35 @@ -{ isLinux, ... }: +{ isLinux, pkgs, ... }: if isLinux then { imports = [ ./dconf.nix ]; - # workaround for https://github.com/nix-community/home-manager/issues/3447 - # autostart 1Password in the background so I can use the SSH agent without manually opening the app first - xdg.configFile."autostart/1password.desktop".text = '' - [Desktop Entry] - Name=1Password - Exec=1password --silent - Terminal=false - Type=Application - Icon=1password - StartupWMClass=1Password - Comment=Password manager and secure wallet - MimeType=x-scheme-handler/onepassword; - Categories=Office; - ''; - # autostart Signal - xdg.configFile."autostart/signal-desktop.desktop".text = '' - [Desktop Entry] - Name=Signal - Exec=signal-desktop --no-sandbox --start-in-tray %U - Terminal=false - Type=Application - Icon=signal-desktop - StartupWMClass=Signal - Comment=Private messaging from your desktop - MimeType=x-scheme-handler/sgnl;x-scheme-handler/signalcaptcha; - Categories=Network;InstantMessaging;Chat; - ''; + xdg.configFile = { + "monitors.xml".source = ../../../conf.d/gnome-monitors.xml; + # workaround for https://github.com/nix-community/home-manager/issues/3447 + # autostart 1Password in the background so I can use the SSH agent without manually opening the app first + "autostart/1password.desktop".text = '' + [Desktop Entry] + Name=1Password + Exec=1password --silent + Terminal=false + Type=Application + Icon=1password + StartupWMClass=1Password + Comment=Password manager and secure wallet + MimeType=x-scheme-handler/onepassword; + Categories=Office; + ''; + # autostart Signal + "autostart/signal-desktop.desktop".text = '' + [Desktop Entry] + Name=Signal + Exec=signal-desktop --no-sandbox --start-in-tray %U + Terminal=false + Type=Application + Icon=signal-desktop + StartupWMClass=Signal + Comment=Private messaging from your desktop + MimeType=x-scheme-handler/sgnl;x-scheme-handler/signalcaptcha; + Categories=Network;InstantMessaging;Chat; + ''; + }; } else { } diff --git a/nixos-modules/desktop_environment.nix b/nixos-modules/desktop_environment.nix index 6ee75c2e..70d02c92 100644 --- a/nixos-modules/desktop_environment.nix +++ b/nixos-modules/desktop_environment.nix @@ -1,4 +1,8 @@ -{ pkgs, ... }: { +{ pkgs, ... }: +let + monitor_config = pkgs.writeText "gdm_monitors.xml" + (builtins.readFile ../conf.d/gnome-monitors.xml); +in { nixpkgs.overlays = [ # GNOME 46: triple-buffering-v4-46 # See: @@ -18,6 +22,10 @@ }); }) ]; + # make GDM use the same monitor config as GNOME; + # see: https://discourse.nixos.org/t/set-external-monitor-as-primary-display-before-login/37844/4 + systemd.tmpfiles.rules = + [ "L+ /run/gdm/.config/monitors.xml - - - - ${monitor_config}" ]; services = { displayManager.defaultSession = "gnome-xorg"; xserver = {