Skip to content

Commit 50152f7

Browse files
committed
feat(hyprland): using hidpi-xprop patch to make xwayland apps scale prefectly
read hyprwm/Hyprland#6446 for more details xcursor size has to scale to x2 by app, because the env var `XCURSOR_SIZE` is also read by wayland apps.
1 parent a563158 commit 50152f7

File tree

4 files changed

+52
-5
lines changed

4 files changed

+52
-5
lines changed

modules/hypr/hyprland/config/monitor.nix

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@
22
monitor = [
33
",preferred,auto,auto"
44
];
5-
xwayland = {
6-
force_zero_scaling = true;
7-
};
85
}

modules/hypr/hyprland/hidpi-xprop.nix

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{pkgs, ...}: {
2+
services.xsettingsd = {
3+
enable = true;
4+
settings = {
5+
"Gdk/UnscaledDPI" = 98304;
6+
"Gdk/WindowScalingFactor" = 2;
7+
};
8+
};
9+
home.packages = with pkgs.xorg; [
10+
xrdb
11+
xprop
12+
];
13+
wayland.windowManager.hyprland.settings = {
14+
exec-once = ["echo \"Xft.dpi: 192\" | xrdb -merge && xprop -root -format _XWAYLAND_GLOBAL_OUTPUT_SCALE 32c -set _XWAYLAND_GLOBAL_OUTPUT_SCALE 2"];
15+
xwayland.use_nearest_neighbor = false;
16+
};
17+
home.sessionVariables.HIDPI_XPROP = 1; # for xwayland app detecting scaling
18+
}

modules/hypr/hyprland/home.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
isVM,
55
...
66
}: {
7+
imports = [./hidpi-xprop.nix];
8+
79
wayland.windowManager.hyprland = {
810
enable = true;
911
# set the flake package

modules/hypr/hyprland/nixos.nix

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
11
{
22
inputs,
3+
lib,
34
pkgs,
45
...
5-
}: {
6+
}: let
7+
# use patch to support scaling xwayland windows
8+
hyprland-patch = pkgs.fetchpatch {
9+
name = "hyprland-hidpi-xprop.patch";
10+
url = "https://patch-diff.githubusercontent.com/raw/hyprwm/Hyprland/pull/6446.patch";
11+
hash = "sha256-60g1EvEoa/733teiMSdUCxfgrwfc/JgWTcDN49D74V4=";
12+
};
13+
xwayland-patch = pkgs.fetchpatch {
14+
name = "xwayland-hidpi-xprop.patch";
15+
url = "https://aur.archlinux.org/cgit/aur.git/plain/hidpi.patch?h=xorg-xwayland-hidpi-xprop";
16+
hash = "sha256-wAsBSyp0B52jC586lDWBV6TTkLuQqEr3juOEus83GTo=";
17+
};
18+
xwayland = pkgs.xwayland.overrideAttrs (previousArgs: {
19+
patches = [xwayland-patch];
20+
mesonFlags =
21+
previousArgs.mesonFlags
22+
++ [
23+
(lib.mesonBool "xvfb" false)
24+
(lib.mesonBool "xdmcp" false)
25+
];
26+
});
27+
in {
628
nix.settings = {
729
# Hyprland cachix
830
substituters = ["https://hyprland.cachix.org"];
@@ -13,8 +35,16 @@
1335
enable = true;
1436
withUWSM = true;
1537

16-
package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland;
38+
package =
39+
(inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland.overrideAttrs {
40+
patches = [hyprland-patch];
41+
})
42+
.override {
43+
inherit xwayland;
44+
};
1745
portalPackage = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-hyprland;
1846
};
47+
environment.systemPackages = [xwayland]; # add patched xwayland to path, idkw it cant be added automatically in hyprland drv
48+
1949
environment.sessionVariables.NIXOS_OZONE_WL = "1";
2050
}

0 commit comments

Comments
 (0)