feat: add hyprlock & hypridle

This commit is contained in:
DACHXY 2025-01-03 22:37:31 +08:00
parent 43bb08b86d
commit e1af19001f
14 changed files with 233 additions and 57 deletions

View file

@ -26,6 +26,13 @@ let
input = import ./hypr/input.nix;
plugins = import ./hypr/plugin.nix;
cursorName = "catppuccin-macchiato-lavender-cursors";
getCurrentSong = pkgs.writeShellScriptBin "getSong" ''
song_info=$(playerctl metadata --format '{{title}} 󰎆 {{artist}}')
echo "$song_info"
'';
hyprlockAccent = "lavender";
in
{
home.packages = with pkgs; [
@ -81,4 +88,74 @@ in
ipc = "on";
};
};
programs.hyprlock = {
enable = true;
importantPrefixes = [
"$"
"monitor"
"size"
"source"
];
extraConfig =
builtins.readFile ../config/hypr/hyprlock.conf
+ ''
# CURRENT SONG
label {
monitor =
text = cmd[update:1000] echo "$(${getCurrentSong}/bin/getSong)"
color = rgba(235, 219, 178, .75)
font_size = 16
font_family = $font, $font2
position = 0, 80
halign = center
valign = bottom
}
'';
};
services.hypridle = {
enable = true;
settings = {
general = {
lock_cmd = "pidof hyprlock || hyprlock";
before_sleep_cmd = "loginctl lock-session";
after_sleep_cmd = "hyprctl dispatch dpms on";
ignore_dbus_inhibit = false;
ignore_systemd_inhibit = false;
};
listener = [
# 2.5min -> set monitor backlight to minimum
{
timeout = 150;
on-timeout = "brightnessctl -s set 10";
on-resume = "brightnessctl -r";
}
# 2.5min -> turn off keyboard backlight
{
timeout = 150;
on-timeout = "brightnessctl -sd rgb:kbd_backlight set 0";
on-resume = "brightnessctl -rd rgb:kbd_backlight";
}
# 5min -> Lock screen
{
timeout = 300;
on-timeout = "loginctl lock-session";
}
# 5.5min -> Screen off
{
timeout = 330;
on-timeout = "hyprctl dispatch dpms off";
on-resume = "hyprctl dispatch dpms on";
}
# 30min -> Suspend pc
# {
# timeout = 1800;
# on-timeout = "systemctl suspend";
# }
];
};
};
}