NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.63k stars 13.78k forks source link

Hyprland: Second monitor doesn't work #303153

Open domodoiddd opened 5 months ago

domodoiddd commented 5 months ago

Describe the bug

I can't connect my laptop to a second monitor, the monitor turns on for a second when I plug in my hdmi cable to the laptop, but after it the screen goes dark again, in my situation hyprland move only first workspace to the second monitor(I expected it to move all of workspaces expect of 7 workspace)

About two-three, may be four days ago I had nixos generations which worked with second monitor on hyprland, but I have deleted those generations, yes, sorry, but I can't tell you a git hash of hyprland at least which worked with second monitor. The same problem is described by three-four other people too, so the problem is neither in last hyprland releases nor in last nixpkgs releases.

Steps To Reproduce

  1. Install nixos 23.11 with hyprland(or switch with enabled hyprland package)
  2. Start hyprland
  3. Try to connect your laptop to second monitor with wdisplays utility or using hyprland configuration file(also you can use other wayland programs to enable second monitor)
ElvishJerricco commented 5 months ago

I asked @domodoiddd to post this because I have seen several people with very similar symptoms in the past few days. It makes me think something in the latest updates might have regressed hyprland.

JohnRTitor commented 3 months ago

Please confirm if you see this on the latest release (0.41.2 as of now)!

domodoiddd commented 2 months ago

Please confirm if you see this on the latest release (0.41.2 as of now)!

On the latest release I get the same result, second monitor doesn't work, wdisplays command/program crashes with error when I connect second monitor, the error is "Gdk-Message: 12:54:13.431: Error 71 (Protocol error) dispatching to Wayland display."

By the way, I used second monitor somehow on hyprland on the previous version, on startup I just connect second monitor to the laptop(so linux/system was turned off) and then after boot... Somehow hyprland worked with second monitor, but there were issues too, but at least it worked, I will try the same with this version later

JohnRTitor commented 2 months ago

CC @fufexan, but this probably should go to upstream

domodoiddd commented 2 months ago

So, I have booted my system with connected second monitor on startup... It works, I even can change dpi in wdisplays settings and nothing crashes, but the same as I said was in the previous version too

fufexan commented 2 months ago

Can you post your config file in a pastebin/gist?

domodoiddd commented 2 months ago

(Sorry for this terrible paste) This code is for all desktop machines:

` programs.xwayland.enable = true; # wether to enable xwayland for system i18n.inputMethod = { enabled = "fcitx5"; fcitx5.addons = with pkgs; [ fcitx5-mozc

fcitx5

  fcitx5-chewing
  fcitx5-configtool
  fcitx5-hangul
  fcitx5-m17n
  fcitx5-mozc
  fcitx5-gtk
];

};

Enable the X11 windowing system.

services.xserver.enable = true;

Configure keymap in X11

services.xserver.xkb.layout = "us"; # was renamed services.xserver.layout = "us";

--- Display manager ---

services.xserver.displayManager.lightdm.enable = true;

services.displayManager.sddm.enable = true;

programs.hyprland.enable = true; # Enable hyprland window manager services= {

Enable touchpad

libinput = {
  enable = true;
  touchpad.middleEmulation = true;
  touchpad.tapping = true;
  touchpad.naturalScrolling = true;
  touchpad.scrollMethod = "twofinger";
  touchpad.disableWhileTyping = true;
  touchpad.accelSpeed = "0.3";
  #touchpad.clickMethod = "clickfinger";
};

};

Make qt application look the same as gtk applications

qt.enable = true; qt.platformTheme = "gtk2"; qt.style = "gtk2";

Enable OpenGL

hardware.opengl = { enable = true; driSupport = true; driSupport32Bit = true; };

hardware.opengl.extraPackages = [ pkgs.mesa.drivers ];

hardware.opengl.extraPackages = [ pkgs.mesa.drivers pkgs."intel-media-driver" pkgs."intel-compute-runtime" pkgs.rocmPackages.clr.icd pkgs.amdvlk

intel-vaapi-driver #for older i965 drivers

];

Enable light

programs.light.enable = true;

`

This code is for my current laptop, yes, sure, I must mention that on this laptop I have two graphic cards: intel + nvidia, this is my specialisation with intel-only enabled graphic card, I think that this must work for sure, but it doesn't work with the second monitor if I don't connect my laptop to second monitor on system boot:

` specialisation = {

Just configuration for usage of only intel videocard

intel-only.configuration = {
  system.nixos.tags = [ "intel-only" ];
  boot.kernelParams = [
    "acpi_rev_override"
    "mem_sleep_default=deep"
    "intel_iommu=igfx_off"
    "intel_iommu=on"
    "iommu=pt"
    "splash"
    "fbcon=font:TER16x32"
    "pcie_aspm=force"
  ];
  services.xserver.videoDrivers = [ "intel" ];
  boot.extraModprobeConfig = ''
    blacklist nouveau
    options nouveau modeset=0
  '';

  services.udev.extraRules = ''
    # Remove NVIDIA USB xHCI Host Controller devices, if present
    ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{power/control}="auto", ATTR{remove}="1"
    # Remove NVIDIA USB Type-C UCSI devices, if present
    ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{power/control}="auto", ATTR{remove}="1"
    # Remove NVIDIA Audio devices, if present
    ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{power/control}="auto", ATTR{remove}="1"
    # Remove NVIDIA VGA/3D controller devices
    ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", ATTR{power/control}="auto", ATTR{remove}="1"
  '';
  boot.blacklistedKernelModules =
    [ "nouveau" "nvidia" "nvidia_drm" "nvidia_modeset" ];

};
# there are other 5 specialisations but I won't show them here

`

Also for all specialisations on these latptop I have these(Now I feel that this can cause an issue): ` services.xserver.dpi = 160; environment.variables = {

GDK_SCALE = "2";

GDK_DPI_SCALE = "1";
_JAVA_OPTIONS = "-Dsun.java2d.uiScale=2";
#WLR_DRM_DEVICES = "/dev/dri/card1 sway";

}; `

And these things too(But I think it can't cause an issue):

` powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; boot.kernelModules = [ "kvm-intel" "vfio" "vfio_iommu_type1" "vfio_pci" "vfio_virqfd" ]; boot.extraModulePackages = [ ];

`

fufexan commented 2 months ago

WLR_DRM_DEVICES can cause issues, but since it seems to be commented out, it won't. As for anything else, I don't see anything obviously wrong. Note that the xserver/libinput configs don't apply to Hyprland.

Can you also paste your hyprland.conf in a https://gist.github.com?

domodoiddd commented 2 months ago

WLR_DRM_DEVICES can cause issues, but since it seems to be commented out, it won't. As for anything else, I don't see anything obviously wrong. Note that the xserver/libinput configs don't apply to Hyprland.

Can you also paste your hyprland.conf in a https://gist.github.com?

https://gist.github.com/domodoiddd/0b922eef22e86304c865b43c929a848a

fufexan commented 2 months ago

Regarding https://gist.github.com/domodoiddd/0b922eef22e86304c865b43c929a848a#file-hyprland-conf-L24-L25, can you comment those lines out and see what Hyprland does on its own? I know there have been cases where monitor= lines would cause issues.

domodoiddd commented 2 months ago

Regarding https://gist.github.com/domodoiddd/0b922eef22e86304c865b43c929a848a#file-hyprland-conf-L24-L25, can you comment those lines out and see what Hyprland does on its own? I know there have been cases where monitor= lines would cause issues.

I disabled those lines, rebooted, connected second monitor, nothing happens(I mean as always the monitor seems to turn on, but there is no image, the monitor turns off after a one/two second/seconds). I tried to use wdisplays in two situations: 1) run wdisplays before connecting the second monitor, I get this error: Gdk-Message: $Time: Error flushing display: Broken pipe Also in the same situation I can get this error: Error 71 (Protocol error) dispatching to Wayland display. 2) run wdisplays when the second monitor is already connected, I get this error: Error flushing display: Protocol error

fufexan commented 2 months ago

No idea then. Can you open an issue in https://github.com/hyprwm/Hyprland?

domodoiddd commented 2 months ago

No idea then. Can you open an issue in https://github.com/hyprwm/Hyprland?

It is opened https://github.com/hyprwm/Hyprland/issues/6926