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" "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": { "hyprland": {
"inputs": { "inputs": {
"hyprland-protocols": "hyprland-protocols", "hyprland-protocols": "hyprland-protocols",
"hyprlang": "hyprlang", "hyprlang": "hyprlang_2",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
], ],
@ -409,6 +430,27 @@
} }
}, },
"hyprlang": { "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": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"hyprland", "hyprland",
@ -429,7 +471,7 @@
"type": "github" "type": "github"
} }
}, },
"hyprlang_2": { "hyprlang_3": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"hyprland", "hyprland",
@ -451,7 +493,7 @@
"type": "github" "type": "github"
} }
}, },
"hyprlang_3": { "hyprlang_4": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"hyprlock", "hyprlock",
@ -472,7 +514,7 @@
"type": "github" "type": "github"
} }
}, },
"hyprlang_4": { "hyprlang_5": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs_3" "nixpkgs": "nixpkgs_3"
}, },
@ -492,7 +534,7 @@
}, },
"hyprlock": { "hyprlock": {
"inputs": { "inputs": {
"hyprlang": "hyprlang_3", "hyprlang": "hyprlang_4",
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
@ -511,7 +553,7 @@
}, },
"hyprpaper": { "hyprpaper": {
"inputs": { "inputs": {
"hyprlang": "hyprlang_4", "hyprlang": "hyprlang_5",
"nixpkgs": "nixpkgs_4" "nixpkgs": "nixpkgs_4"
}, },
"locked": { "locked": {
@ -897,6 +939,7 @@
"hardware": "hardware", "hardware": "hardware",
"helix": "helix", "helix": "helix",
"home-manager": "home-manager", "home-manager": "home-manager",
"hypridle": "hypridle",
"hyprland": "hyprland", "hyprland": "hyprland",
"hyprland-plugins": "hyprland-plugins", "hyprland-plugins": "hyprland-plugins",
"hyprlock": "hyprlock", "hyprlock": "hyprlock",
@ -1106,7 +1149,7 @@
"hyprland", "hyprland",
"hyprland-protocols" "hyprland-protocols"
], ],
"hyprlang": "hyprlang_2", "hyprlang": "hyprlang_3",
"nixpkgs": [ "nixpkgs": [
"hyprland", "hyprland",
"nixpkgs" "nixpkgs"

View file

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

View file

@ -1,12 +1,22 @@
{ lib, config, inputs, ... }: { lib, config, inputs, pkgs, ... }:
let let
cfg = config.homeModules.desktop.wayland.lockscreen.hyprlock; cfg = config.homeModules.desktop.wayland.lockscreen.hyprlock;
inherit (config.colorscheme) colors; 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 in
{ {
imports = [ inputs.hyprlock.homeManagerModules.hyprlock ]; imports = [
inputs.hyprlock.homeManagerModules.default
inputs.hypridle.homeManagerModules.default
];
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home.sessionVariables.LOCKER = "hyprlock"; 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 = { wayland = {
base.enable = true; base.enable = true;
windowManager.hyprland.enable = true; windowManager.hyprland.enable = true;
lockscreen.swaylock.enable = true; lockscreen.hyprlock.enable = true;
notification.mako.enable = true; notification.mako.enable = true;
bar.ags.enable = true; bar.ags.enable = true;
}; };