Skip to content

Commit

Permalink
feat(gnome): Declaratively set monitor config
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjones2014 committed Sep 29, 2024
1 parent ddefe0f commit 4ec33c2
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 29 deletions.
71 changes: 71 additions & 0 deletions conf.d/gnome-monitors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<monitors version="2">
<configuration>
<logicalmonitor>
<x>0</x>
<y>1440</y>
<scale>1</scale>
<primary>yes</primary>
<monitor>
<monitorspec>
<connector>DP-2</connector>
<vendor>GSM</vendor>
<product>LG ULTRAWIDE</product>
<serial>207NTYT1A970</serial>
</monitorspec>
<mode>
<width>5120</width>
<height>1440</height>
<rate>143.979</rate>
</mode>
</monitor>
</logicalmonitor>
<logicalmonitor>
<x>5120</x>
<y>320</y>
<scale>1</scale>
<transform>
<rotation>left</rotation>
<flipped>no</flipped>
</transform>
<monitor>
<monitorspec>
<connector>HDMI-0</connector>
<vendor>VSC</vendor>
<product>VX2478 Series</product>
<serial>UPN172200089</serial>
</monitorspec>
<mode>
<width>2560</width>
<height>1440</height>
<rate>59.951</rate>
</mode>
</monitor>
</logicalmonitor>
<logicalmonitor>
<x>1680</x>
<y>0</y>
<scale>1</scale>
<monitor>
<monitorspec>
<connector>HDMI-1</connector>
<vendor>SPT</vendor>
<product>Sceptre C35</product>
<serial>0000000000000</serial>
</monitorspec>
<mode>
<width>3440</width>
<height>1440</height>
<rate>59.999</rate>
</mode>
</monitor>
</logicalmonitor>
<disabled>
<monitorspec>
<connector>DP-1</connector>
<vendor>SAM</vendor>
<product>SAMSUNG</product>
<serial>0x01000e00</serial>
</monitorspec>
</disabled>
</configuration>
</monitors>
59 changes: 31 additions & 28 deletions home-manager/modules/gnome/default.nix
Original file line number Diff line number Diff line change
@@ -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
{ }
10 changes: 9 additions & 1 deletion nixos-modules/desktop_environment.nix
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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 = {
Expand Down

0 comments on commit 4ec33c2

Please sign in to comment.