From 0ce48b8c6c02204e68acf65f8c36254e87e91f6a Mon Sep 17 00:00:00 2001
From: Jens Nolte <jens@nightmarestudio.de>
Date: Wed, 11 Dec 2019 21:25:12 +0100
Subject: [PATCH] Fix XWayland dpi

---
 home-profiles/desktop/.Xresources         |  3 +++
 home-profiles/desktop/.config/sway/config |  3 +++
 nixos/layers/desktop.nix                  | 12 +++++-------
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/home-profiles/desktop/.Xresources b/home-profiles/desktop/.Xresources
index bb86d3f..45377b2 100644
--- a/home-profiles/desktop/.Xresources
+++ b/home-profiles/desktop/.Xresources
@@ -40,3 +40,6 @@ xterm*foreground: lightgray
 
 ! terminal: dark background
 XTerm.vt100.reverseVideo: true
+
+! XWayland DPI Fix
+Xft.dpi: 96
diff --git a/home-profiles/desktop/.config/sway/config b/home-profiles/desktop/.config/sway/config
index b9fd9dc..37a560c 100644
--- a/home-profiles/desktop/.config/sway/config
+++ b/home-profiles/desktop/.config/sway/config
@@ -67,6 +67,9 @@ exec CM_SELECTIONS=clipboard clipmenud
 #exec nm-applet --indicator
 exec redshift -m wayland
 
+# Fix XWayland DPI
+exec xrdb -load ~/.Xresources
+
 # Share wayland socket with other users
 # This should allocate a free socket instead
 # Also requires passwordless sudo, so it's currently disabled
diff --git a/nixos/layers/desktop.nix b/nixos/layers/desktop.nix
index ecd0b2c..c20e231 100644
--- a/nixos/layers/desktop.nix
+++ b/nixos/layers/desktop.nix
@@ -73,10 +73,8 @@ in
   };
 
 
-
-
   programs.sway.enable = true;
-  programs.sway.extraPackages = with pkgs; [ swaylock swayidle xwayland kitty cool-retro-term ];
+  programs.sway.extraPackages = with pkgs; [ swaylock swayidle xwayland kitty cool-retro-term xorg.xrdb ];
   # QT_QPA_PLATFORM=wayland requires qt5.qtwayland in systemPackages
   programs.sway.extraSessionCommands = ''
 export SDL_VIDEODRIVER=wayland
@@ -84,9 +82,9 @@ export QT_QPA_PLATFORM=wayland
 export QT_WAYLAND_DISABLE_WINDOWDECORATION="1"
   '';
   environment.loginShellInit = ''
-# start sway when logging in on tty1
-if [ "$USER" = jens ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ] && [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ]; then
-exec sway &> /run/user/$UID/sway_log
-fi
+    # start sway when logging in on tty1
+    if [ "$USER" = jens ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ] && [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ]; then
+    exec sway &> /run/user/$UID/sway_log
+    fi
   '';
 }
-- 
GitLab