hyprwm / hyprlock

Hyprland's GPU-accelerated screen locking utility
BSD 3-Clause "New" or "Revised" License
794 stars 59 forks source link

Hyprlock only works when I manually type in hyprlock in terminal (NixOS) #295

Closed cachedpotato closed 6 months ago

cachedpotato commented 6 months ago

Hello, I'm quite new to NixOS and just Linux in general, and I'm having this weird issue with hyprlock. So I only recently figured out I can configure hyprlock in nix language. So instead of just dumping the entire config file as a giant string ( home.file.".config/hypr/hyprlock.conf".text = ''....'';), I changed my hyprlock.nix like so:

{pkgs, config, lib, stylix, inputs, ...}:
{
  imports = [
    inputs.hyprlock.homeManagerModules.default
  ];

  programs.hyprlock = {
    enable = true;
    general = {
      disable_loading_bar = false;
      grace = 0;
      hide_cursor = true;
      no_fade_in = false;
      no_fade_out = false;
    };

    backgrounds = [
      {
        monitor = "eDP-1";
        path = "/home/lowlife/.flake_configs/wallpapers/hakurei_reimu_lock_1.jpg";
        blur_passes = 0;
        #blur_size = 8;
        #noise = 0.0117;
        #contrast = 0.8917;
      }
    ];

    input-fields = [
      {
        monitor = "eDP-1";
        size.width = 200; #default 200
        size.height = 50; #default 50
        outline_thickness = 3; #default 3
        dots_size = 0.33; #default 0.33
        dots_spacing = 0.18; #default 0.15
        dots_center = true; #center position of the dots
        outer_color = "rgb(" + config.lib.stylix.colors.base07-rgb-r + "," + config.lib.stylix.colors.base07-rgb-g + "," + config.lib.stylix.colors.base07-rgb-b + ")";
        inner_color = "rgb(" + config.lib.stylix.colors.base00-rgb-r + "," + config.lib.stylix.colors.base00-rgb-g + "," + config.lib.stylix.colors.base00-rgb-b + ")";
        font_color = "rgb(20, 20, 20)"; #default
        fade_on_empty = true;
        fade_timeout = 2000; #default 2000, ms
        fail_color =  "rgb(" + config.lib.stylix.colors.base08-rgb-r + "," + config.lib.stylix.colors.base08-rgb-g + "," + config.lib.stylix.colors.base08-rgb-b + ")";
        fail_transition = 300; #default 300 ms
        position.x = 0;
        position.y = -20;
        halign = "center";
        valign = "center";
      }
    ];

    labels = [
      {
        monitor = "eDP-1";
        text = "Welcome Back, $USER";
        color = "rgb(" + config.lib.stylix.colors.base07-rgb-r + "," + config.lib.stylix.colors.base07-rgb-g + "," + config.lib.stylix.colors.base07-rgb-b + ")"; 
        font_size = 25; #default 25
        font_family = "Noto Sans";
        position.x = 0;
        position.y = 80;
        halign = "center";
        valign = "center";
      }
      {
        monitor = "eDP-1";
        text = "$TIME";
        color = "rgba(200, 200, 200, 1.0)"; #default
        font_size = 70; #default 25
        font_family = "Noto Sans";
        position.x = 0;
        position.y = 140;
        halign = "center";
        valign = "center";
      }
    ];
  };
}

Nothing special really, but after I set it up like this, hyprlock kinda stopped working. To be more specific, when I close my laptop and re-open it, it seems like my laptop is trying to load SOMETHING but fails (hyprlock did take 1-2 seconds to load properly before) and for some reason my cursor gets bigger, but that's it. nothing else happens. The weird part is, when I type in hyprlock in my terminal it works just fine.

I do use hypridle as well, so I tweaked my settings a bit like so:

{pkgs, inputs, lib, config, ...}:
{
  imports = [
    inputs.hypridle.homeManagerModules.default
  ];

  services.hypridle = {
    enable = true;
    lockCmd = "pidof hyprlock || hyprlock";
    beforeSleepCmd = "loginctl lock-session";
    afterSleepCmd = "hyprctl dispatch dpms on";
    ignoreDbusInhibit = true;
    .....

But I this didn't solve the issue as well. I didn't see anything wrong with my .config/hypr/hyprlock.conf file either. Like I said, I'm new to NixOS so I may have made a dumb mistake somewhere, but I really don't know what to look for. Any help would be greatly appreciated. if you need any additional info please let me know.

Thanks!

vaxerski commented 6 months ago

@fufexan for nix

cachedpotato commented 6 months ago

couldn't reach him personally but thankfully he had a public repo for his NixOS configurations and I fixed it by simply adding this to my hyprland.nix:

exec-once = "hyprlock"

I swear I didn't have this line in my previous config but it still worked... not sure what's going on but but hey it loads now. I just have one more question - so my hyprlock screen loads now but there's this 2-3 second window where my lock screen and my computer screen overlaps, and I can't really type or do anything. Here's a screenshot: KakaoTalk_20240427_195235284 (sorry for the poor image quality)

Is this normal behavior or is there anything else I should do? I'm not sure if this is a NixOS-specific problem.

Thanks!

fufexan commented 6 months ago

Regarding your first comment, the proper fix (if you use the HM module) is to set wayland.windowManager.hyprland.systemd.variables = ["--all"];. This is because systemd doesn't have access to PATH otherwise, so it can't find the hyprlock binary.

Your second comment describes something I sometimes see on my laptop as well. Looks like everything is "frozen" for 1-2 seconds. I'm pretty sure it's something to do with amdgpu not waking up the gpu fast enough.

According to `dmesg`: ``` [65743.107795] ACPI: EC: interrupt blocked [67210.349689] ACPI: EC: interrupt unblocked [67210.671843] [drm] PCIE GART of 1024M enabled. [67210.671850] [drm] PTB located at 0x000000F41FC00000 [67210.671877] amdgpu 0000:03:00.0: amdgpu: SMU is resuming... [67210.673134] nvme nvme0: Shutdown timeout set to 8 seconds [67210.673904] amdgpu 0000:03:00.0: amdgpu: dpm has been disabled [67210.674819] amdgpu 0000:03:00.0: amdgpu: SMU is resumed successfully! [67210.691855] nvme nvme0: 16/0/0 default/read/poll queues [67211.552091] [drm] VCN decode and encode initialized successfully(under DPG Mode). [67211.552325] [drm] JPEG decode initialized successfully. [67211.552333] amdgpu 0000:03:00.0: amdgpu: ring gfx uses VM inv eng 0 on hub 0 [67211.552335] amdgpu 0000:03:00.0: amdgpu: ring gfx_low uses VM inv eng 1 on hub 0 [67211.552337] amdgpu 0000:03:00.0: amdgpu: ring gfx_high uses VM inv eng 4 on hub 0 [67211.552338] amdgpu 0000:03:00.0: amdgpu: ring comp_1.0.0 uses VM inv eng 5 on hub 0 [67211.552339] amdgpu 0000:03:00.0: amdgpu: ring comp_1.1.0 uses VM inv eng 6 on hub 0 [67211.552341] amdgpu 0000:03:00.0: amdgpu: ring comp_1.2.0 uses VM inv eng 7 on hub 0 [67211.552342] amdgpu 0000:03:00.0: amdgpu: ring comp_1.3.0 uses VM inv eng 8 on hub 0 [67211.552343] amdgpu 0000:03:00.0: amdgpu: ring comp_1.0.1 uses VM inv eng 9 on hub 0 [67211.552344] amdgpu 0000:03:00.0: amdgpu: ring comp_1.1.1 uses VM inv eng 10 on hub 0 [67211.552345] amdgpu 0000:03:00.0: amdgpu: ring comp_1.2.1 uses VM inv eng 11 on hub 0 [67211.552346] amdgpu 0000:03:00.0: amdgpu: ring comp_1.3.1 uses VM inv eng 12 on hub 0 [67211.552348] amdgpu 0000:03:00.0: amdgpu: ring kiq_0.2.1.0 uses VM inv eng 13 on hub 0 [67211.552349] amdgpu 0000:03:00.0: amdgpu: ring sdma0 uses VM inv eng 0 on hub 8 [67211.552350] amdgpu 0000:03:00.0: amdgpu: ring vcn_dec uses VM inv eng 1 on hub 8 [67211.552351] amdgpu 0000:03:00.0: amdgpu: ring vcn_enc0 uses VM inv eng 4 on hub 8 [67211.552352] amdgpu 0000:03:00.0: amdgpu: ring vcn_enc1 uses VM inv eng 5 on hub 8 [67211.552353] amdgpu 0000:03:00.0: amdgpu: ring jpeg_dec uses VM inv eng 6 on hub 8 [67212.799544] OOM killer enabled. [67212.799547] Restarting tasks ... done. ``` Looks like it takes 2 seconds to restart tasks from the moment the EC interrupt was unblocked.
cachedpotato commented 6 months ago

Thank you for your help! Really appreciate it. As for the freezing issue, my laptop doesn't use AMD GPU so I got curious, and looking at the dmesg I found out that 1) I still don't know how to understand all this and 2) for some reason my bluetooth is failing:

[  209.164423] ACPI: EC: interrupt unblocked
[  210.631222] ACPI: EC: event unblocked
[  210.641735] i915 0000:00:02.0: [drm] [ENCODER:94:DDI A/PHY A] is disabled/in DSI mode with an ungated DDI clock, gate it
[  210.641752] i915 0000:00:02.0: [drm] [ENCODER:102:DDI B/PHY B] is disabled/in DSI mode with an ungated DDI clock, gate it
[  210.641765] i915 0000:00:02.0: [drm] [ENCODER:118:DDI C/PHY C] is disabled/in DSI mode with an ungated DDI clock, gate it
[  210.656725] nvme nvme0: 7/0/0 default/read/poll queues
[  210.862664] usb 2-3: reset SuperSpeed USB device number 2 using xhci_hcd
[  210.893803] sd 0:0:0:0: [sda] Starting disk
[  210.995782] usb 1-3: reset full-speed USB device number 2 using xhci_hcd
[  211.238381] usb 1-7: reset full-speed USB device number 3 using xhci_hcd
[  211.479349] usb 1-8: reset high-speed USB device number 4 using xhci_hcd
[  214.467152] sd 0:0:0:0: [sda] Start/Stop Unit failed: Result: hostbyte=DID_OK driverbyte=DRIVER_OK
[  214.467167] sd 0:0:0:0: [sda] Sense Key : Not Ready [current]
[  214.467174] sd 0:0:0:0: [sda] Add. Sense: Medium not present
[  214.467186] sd 0:0:0:0: [sda] Starting disk
[  214.477797] pci_bus 0000:06: Allocating resources
[  214.477845] pci_bus 0000:3c: Allocating resources
[  214.477854] mei_hdcp 0000:00:16.0-b638ab7e-94e2-4ea2-a552-d1c54b627f04: bound 0000:00:02.0 (ops i915_hdcp_ops [i915])
[  214.478909] pci_bus 0000:06: Allocating resources
[  214.478933] pci_bus 0000:3c: Allocating resources
[  214.479219] OOM killer enabled.
[  214.479225] Restarting tasks ...
[  214.482698] usb 1-9: USB disconnect, device number 6
[  214.483080] Bluetooth: hci0: Bootloader revision 0.0 build 26 week 38 2015
[  214.483217] done.
[  214.483241] random: crng reseeded on system resumption
[  214.484229] Bluetooth: hci0: Device revision is 16
[  214.484241] Bluetooth: hci0: Secure boot is enabled
[  214.484243] Bluetooth: hci0: OTP lock is enabled
[  214.484245] Bluetooth: hci0: API lock is enabled
[  214.484246] Bluetooth: hci0: Debug lock is disabled
[  214.484247] Bluetooth: hci0: Minimum firmware build 1 week 10 2014
[  214.510233] PM: suspend exit
[  214.538094] Bluetooth: hci0: Found device firmware: intel/ibt-12-16.sfi
[  214.598061] usb 1-9: new full-speed USB device number 7 using xhci_hcd
[  214.600289] e1000e 0000:00:1f.6 enp0s31f6: NIC Link is Down
[  214.726112] usb 1-9: New USB device found, idVendor=06cb, idProduct=009a, bcdDevice= 1.64
[  214.726127] usb 1-9: New USB device strings: Mfr=0, Product=0, SerialNumber=1
[  214.726135] usb 1-9: SerialNumber: dfb89886655a
[  216.412805] Bluetooth: hci0: Waiting for firmware download to complete
[  216.412995] Bluetooth: hci0: Firmware loaded in 1831194 usecs
[  216.413096] Bluetooth: hci0: Waiting for device to boot
[  216.426089] Bluetooth: hci0: Device booted in 12731 usecs
[  216.426554] Bluetooth: hci0: Found Intel DDC parameters: intel/ibt-12-16.ddc
[  216.429112] Bluetooth: hci0: Applying Intel DDC parameters completed
[  216.430125] Bluetooth: hci0: Firmware revision 0.1 build 19 week 44 2021
[  216.432135] Bluetooth: hci0: Reading supported features failed (-16)
[  216.432145] Bluetooth: hci0: Error reading debug features
[  216.432151] Bluetooth: hci0: HCI LE Coded PHY feature bit is set, but its usage is not supported.
[  216.483740] Bluetooth: MGMT ver 1.22
[  217.982753] wlp61s0: authenticate with 0c:96:cd:38:61:33
[  217.982772] wlp61s0: 80 MHz not supported, disabling VHT
[  217.992982] wlp61s0: send auth to 0c:96:cd:38:61:33 (try 1/3)
[  218.011193] wlp61s0: authenticated
[  218.012717] wlp61s0: associate with 0c:96:cd:38:61:33 (try 1/3)
[  218.015520] wlp61s0: RX AssocResp from 0c:96:cd:38:61:33 (capab=0x411 status=0 aid=18)
[  218.015534] wlp61s0: AP has invalid WMM params (AIFSN=1 for ACI 3), will use 2
[  218.020086] wlp61s0: associated

some usb related jargon too, so I guess I should check that out as well.

Again, thank you for the assistance! Closing the issue as whatever problems my laptop have don't seem like a hyprlock problem.