feat: implement hyprlock and hypridle

This commit is contained in:
Nickolaj Jepsen 2025-04-15 23:48:15 +02:00
parent 870f8fdde5
commit 0d47ab58f5
4 changed files with 146 additions and 8 deletions

View file

@ -65,6 +65,8 @@ in {
imports = [
./hyprpolkitagent.nix
./hyprpaper.nix
./hyprlock.nix
./hypridle.nix
];
config = {
@ -132,7 +134,10 @@ in {
)
config.monitors;
exec = ["systemctl --user start hyprpaper"];
exec = [
"systemctl --user start hyprpaper"
"systemctl --user start hypridle"
];
input = {
# Most unknown keyboards will be of the DK layout, we set known keyboards to eu in `devices`
@ -247,7 +252,7 @@ in {
"SUPER, BACKSPACE, killactive"
"SUPER, SPACE, exec, astal launcher"
"SUPER, semicolon, exec, astal launcher .e"
"SUPER, p, exec, ${getExe config.programs.uwsm.package} app -- loginctl lock-session"
"SUPER, p, exec, ${getExe config.programs.uwsm.package} app -- ${pkgs.systemd}/bin/loginctl lock-session"
", Print, exec, ${lib.getExe pkgs.grimblast} save area - | ${lib.getExe pkgs.satty} -f -"
"SHIFT, Print, exec, ${lib.getExe pkgs.grimblast} --freeze save area - | ${lib.getExe pkgs.satty} -f -"

View file

@ -0,0 +1,34 @@
{
config,
pkgs,
...
}:
let
sleep_cmd = "${config.programs.hyprland.package}/bin/hyprctl dispatch dpms off";
wake_cmd = "${config.programs.hyprland.package}/bin/hyprctl dispatch dpms on";
lock_cmd = "pidof ${pkgs.hyprlock}/bin/hyprlock || ${pkgs.hyprlock}/bin/hyprlock";
in {
config = {
fireproof.home-manager.services.hypridle = {
enable = true;
settings = {
general = {
inherit lock_cmd;
before_sleep_cmd = "${pkgs.systemd}/bin/loginctl lock-session";
after_sleep_cmd = sleep_cmd;
};
listener = [
{
timeout = 60 * 5;
on-timeout = lock_cmd;
}
{
timeout = 60 * 15;
on-timeout = sleep_cmd;
on-resume = wake_cmd;
}
];
};
};
};
}

View file

@ -0,0 +1,99 @@
{
lib,
config,
inputs,
pkgs,
...
}:
let
background = pkgs.stdenvNoCC.mkDerivation {
pname = "desktop-background";
version = "0.2";
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./backgrounds/unknown.svg
];
};
nativeBuildInputs = [pkgs.inkscape];
buildPhase = ''
inkscape -w 3840 -h 2160 backgrounds/unknown.svg -o unknown.png
'';
installPhase = ''
mkdir -p $out/share/backgrounds
cp *.svg *.png $out/share/backgrounds
'';
};
# Re-use the same color scheme as in the main Hyprland config
color = {
bg = "rgb(28, 27, 26)";
ui = "rgb(52, 51, 49)";
fg = "rgb(218, 216, 206)";
transparent = "rgba(0, 0, 0, 0)";
};
in {
config = {
fireproof.home-manager.programs.hyprlock = {
enable = true;
settings = {
general = {
disable_loading_bar = false;
grace = 0;
no_fade_in = false;
};
background = {
monitor = "";
color = color.bg;
path = background + "/share/backgrounds/unknown.png";
};
input-field = {
monitor = "";
size = "250, 60";
outline_thickness = 2;
dots_size = 0.2;
dots_spacing = 0.2;
dots_center = true;
outer_color = color.transparent;
inner_color = color.ui;
font_color = color.fg;
fade_on_empty = false;
font_family = "Hack Nerd Font";
placeholder_text = "";
hide_input = false;
position = "0, -35";
halign = "center";
valign = "center";
rounding = 8;
};
shape = [
{
monitor = "";
color = color.ui;
halign = "center";
valign = "center";
size = "150, 60";
position = "0, 35";
rounding = 8;
}
];
label = [
{
monitor = "";
text = "cmd[update:1000] echo \"<span>$(date +\"%H:%M\")</span>\"";
color = color.fg;
font_size = 30;
font_family = "Hack Nerd Font";
position = "0, 35";
halign = "center";
valign = "center";
}
];
};
};
};
}