feat: hypridle init config

This commit is contained in:
ooks-io 2024-02-23 21:08:49 +13:00
parent 501c7fdf07
commit 4e20345a93
4 changed files with 80 additions and 12 deletions

57
flake.lock generated
View file

@ -338,10 +338,31 @@
"type": "github"
}
},
"hypridle": {
"inputs": {
"hyprlang": "hyprlang",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1708597999,
"narHash": "sha256-Glwi2jMjT/fCMbRGun+zoZOE6nQ053XfFfFuqi23+ds=",
"owner": "hyprwm",
"repo": "hypridle",
"rev": "b85722e41aeb9925f248e9b3fe8427475cb1eb6b",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hypridle",
"type": "github"
}
},
"hyprland": {
"inputs": {
"hyprland-protocols": "hyprland-protocols",
"hyprlang": "hyprlang",
"hyprlang": "hyprlang_2",
"nixpkgs": [
"nixpkgs"
],
@ -409,6 +430,27 @@
}
},
"hyprlang": {
"inputs": {
"nixpkgs": [
"hypridle",
"nixpkgs"
]
},
"locked": {
"lastModified": 1708212860,
"narHash": "sha256-nW3Zrhh9RJcMTvOcXAaKADnJM/g6tDf3121lJtTHnYo=",
"owner": "hyprwm",
"repo": "hyprlang",
"rev": "11d5ccda071c153dfdc18ef65338956a51cef96a",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hyprlang",
"type": "github"
}
},
"hyprlang_2": {
"inputs": {
"nixpkgs": [
"hyprland",
@ -429,7 +471,7 @@
"type": "github"
}
},
"hyprlang_2": {
"hyprlang_3": {
"inputs": {
"nixpkgs": [
"hyprland",
@ -451,7 +493,7 @@
"type": "github"
}
},
"hyprlang_3": {
"hyprlang_4": {
"inputs": {
"nixpkgs": [
"hyprlock",
@ -472,7 +514,7 @@
"type": "github"
}
},
"hyprlang_4": {
"hyprlang_5": {
"inputs": {
"nixpkgs": "nixpkgs_3"
},
@ -492,7 +534,7 @@
},
"hyprlock": {
"inputs": {
"hyprlang": "hyprlang_3",
"hyprlang": "hyprlang_4",
"nixpkgs": "nixpkgs_2"
},
"locked": {
@ -511,7 +553,7 @@
},
"hyprpaper": {
"inputs": {
"hyprlang": "hyprlang_4",
"hyprlang": "hyprlang_5",
"nixpkgs": "nixpkgs_4"
},
"locked": {
@ -897,6 +939,7 @@
"hardware": "hardware",
"helix": "helix",
"home-manager": "home-manager",
"hypridle": "hypridle",
"hyprland": "hyprland",
"hyprland-plugins": "hyprland-plugins",
"hyprlock": "hyprlock",
@ -1106,7 +1149,7 @@
"hyprland",
"hyprland-protocols"
],
"hyprlang": "hyprlang_2",
"hyprlang": "hyprlang_3",
"nixpkgs": [
"hyprland",
"nixpkgs"

View file

@ -44,6 +44,11 @@
hyprlock.url = "github:hyprwm/hyprlock";
hypridle = {
url = "github:hyprwm/hypridle";
inputs.nixpkgs.follows = "nixpkgs";
};
hyprpaper.url = "github:hyprwm/hyprpaper";
helix = {

View file

@ -1,12 +1,22 @@
{ lib, config, inputs, ... }:
{ lib, config, inputs, pkgs, ... }:
let
cfg = config.homeModules.desktop.wayland.lockscreen.hyprlock;
inherit (config.colorscheme) colors;
suspendScript = pkgs.writeShellScript "suspend-script" ''
${pkgs.pipewire}/bin/pw-cli i all | ${pkgs.ripgrep}/bin/rg running
# only suspend if audio isn't running
if [ $? == 1 ]; then
${pkgs.systemd}/bin/systemctl suspend
fi
'';
in
{
imports = [ inputs.hyprlock.homeManagerModules.hyprlock ];
imports = [
inputs.hyprlock.homeManagerModules.default
inputs.hypridle.homeManagerModules.default
];
config = lib.mkIf cfg.enable {
home.sessionVariables.LOCKER = "hyprlock";
@ -67,7 +77,17 @@ in
}
];
};
services.hypridle = {
enable = true;
beforeSleepCmd = "${pkgs.systemd}/bin/loginctl lock-session";
lockCmd = lib.getExe config.programs.hyprlock.package;
listeners = [
{
timeout = 330;
onTimeout = suspendScript.outPath;
}
];
};
};
}

View file

@ -13,7 +13,7 @@ in
wayland = {
base.enable = true;
windowManager.hyprland.enable = true;
lockscreen.swaylock.enable = true;
lockscreen.hyprlock.enable = true;
notification.mako.enable = true;
bar.ags.enable = true;
};