From f93d400ad9eddd04c9209088b0e7fc4c13fb0539 Mon Sep 17 00:00:00 2001 From: Emmet Date: Thu, 4 Apr 2024 13:07:18 -0500 Subject: [PATCH] Fixed my usb hub crashing systemctl suspend --- system/hardware-configuration.nix | 29 +++++++++++++++++++++++++++++ user/wm/hyprland/hyprland.nix | 16 +++++----------- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/system/hardware-configuration.nix b/system/hardware-configuration.nix index eac3ab7..86b0e83 100644 --- a/system/hardware-configuration.nix +++ b/system/hardware-configuration.nix @@ -19,6 +19,35 @@ "L+ /opt/rocm/hip - - - - ${pkgs.rocmPackages.clr}" ]; + # my stupid usb hub crashes systemct suspend half of the time now + # https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Sleep_hooks + systemd.services.root-suspend = { + enable = true; + description = "Root systemd suspend prehook"; + unitConfig = { + Description = "Root systemd suspend prehook"; + Before = "sleep.target"; + }; + serviceConfig = { + Type = "simple"; + ExecStart = "${pkgs.uhubctl}/bin/uhubctl -a off"; + }; + wantedBy = [ "sleep.target" ]; + }; + systemd.services.root-resume = { + enable = true; + description = "Root systemd suspend posthook"; + unitConfig = { + Description = "Root systemd suspend posthook"; + After = "suspend.target"; + }; + serviceConfig = { + Type = "simple"; + ExecStart = "${pkgs.uhubctl}/bin/uhubctl -a on"; + }; + wantedBy = [ "suspend.target" ]; + }; + services.btrfs.autoScrub = { enable = true; interval = "weekly"; diff --git a/user/wm/hyprland/hyprland.nix b/user/wm/hyprland/hyprland.nix index 0b80863..5cfa622 100644 --- a/user/wm/hyprland/hyprland.nix +++ b/user/wm/hyprland/hyprland.nix @@ -136,7 +136,7 @@ bind=,code:255,exec,airplane-mode bind=SUPER,C,exec,wl-copy $(hyprpicker) - bind=SUPERSHIFT,S,exec,hyprlock & sleep 1 && systemctl suspend + bind=SUPERSHIFT,S,exec,systemctl suspend bind=SUPERCTRL,L,exec,hyprlock bind=SUPER,H,movefocus,l @@ -380,20 +380,14 @@ ]; home.file.".config/hypr/hypridle.conf".text = '' general { - lock_cmd = hyprlock - unlock_cmd = - before_sleep_cmd = hyprlock - after_sleep_cmd = + lock_cmd = pgrep hyprlock || hyprlock + before_sleep_cmd = loginctl lock-session ignore_dbus_inhibit = false } listener { - timeout = 360 # in seconds - on-timeout = hyprlock - on-resume = - timeout = 720 # in seconds - on-timeout = systemctl suspend - on-resume = + timeout = 600 # in seconds + on-timeout = loginctl lock-session } ''; home.file.".config/hypr/hyprlock.conf".text = ''