feat: use hypridle and hyprlock
All checks were successful
/ check (push) Successful in 5m27s

This commit is contained in:
Daniel Flanagan 2024-12-21 17:10:45 -06:00
parent 43c3db7f8a
commit afaa34df91
5 changed files with 249 additions and 95 deletions

View file

@ -35,6 +35,76 @@
}; };
}; };
eww = {
programs.eww = {
enable = true;
# NOTE: might be better as a mk out of store symlink or w/e
configDir = ./eww;
};
};
mako = {
config,
pkgs,
...
}: {
services.mako = {
enable = true;
extraConfig = with style.colors.withHashPrefix; ''
border-size=2
border-radius=5
padding=10,15
max-visible=5
default-timeout=15000
font=Symbols Nerd Font ${toString style.font.size},${style.font.name} ${toString style.font.size}
anchor=top-right
on-notify=exec ${pkgs.mpv}/bin/mpv --volume=50 ~/.notify.wav
actions=1
icons=1
width=400
height=150
background-color=${bg}DD
text-color=${text}
border-color=${primary}
progress-color=${primary}
[urgency=high]
border-color=${urgent}
[urgency=high]
background-color=${urgent}EE
border-color=${urgent}
text-color=${bg}
'';
};
};
tofi = {
config,
pkgs,
...
}: {
programs.tofi = {
enable = true;
settings = {
font = "${pkgs.iosevkaLyteTerm}/share/fonts/truetype/IosevkaLyteTerm-regular.ttf";
font-size = 12;
text-color = "#f8f8f8";
prompt-color = "#f38ba8";
selection-color = "#66d9ef";
background-color = "#1e1e2e";
outline-width = 0;
border-width = 1;
border-color = "#66d9ef";
width = 640;
height = 400;
fuzzy-match = "true";
};
};
};
broot = {}; broot = {};
emacs = {pkgs, ...}: { emacs = {pkgs, ...}: {
@ -1135,7 +1205,14 @@
}; };
}; };
hyprland = import ./hyprland.nix; hyprland = {
imports = with homeManagerModules; [
tofi
mako
eww
(import ./hyprland.nix)
];
};
iex = { iex = {
home.file.".iex.exs" = { home.file.".iex.exs" = {

View file

@ -1,6 +0,0 @@
{...}: {
programs.eww = {
enable = true;
configDir = ./eww;
};
}

View file

@ -8,19 +8,9 @@
}: let }: let
inherit (style) colors; inherit (style) colors;
in { in {
imports = [ # TODO: Hyprland seems to sometimes use a ton of CPU?
./ewwbar.nix
# ./mako.nix
# ./swaylock.nix
# TODO: figure out how to import this for this module _and_ for the sway module?
# ./linux-desktop.nix
];
# TODO: Hyprland seems to have issues with resuming from hibernation on my
# laptop where it uses a ton of CPU.
home.packages = with pkgs; [ home.packages = with pkgs; [
# TODO: integrate osd
swayosd swayosd
]; ];
@ -54,29 +44,7 @@ in {
"[workspace 1 silent] wezterm" "[workspace 1 silent] wezterm"
"xwaylandvideobridge" "xwaylandvideobridge"
"systemctl --user import-environment QT_QPA_PLATFORMTHEME" "systemctl --user import-environment QT_QPA_PLATFORMTHEME"
# "wezterm" "hypridle"
# NOTE: maybe check out hypridle?
(lib.concatStringsSep " " [
"swayidle -w"
"before-sleep 'swaylock'"
"timeout 300 'notify-send \"Idling in 5 minutes\"' resume 'notify-send \"Idling cancelled.\"'"
"timeout 480 'notify-send -u critical \"Idling in 2 minutes\"'"
"timeout 510 'notify-send -u critical \"Idling in 90 seconds\"'"
"timeout 540 'notify-send -u critical \"Idling in 60 seconds!\"'"
"timeout 570 'notify-send -u critical \"Idling in 30 seconds!\"'"
"timeout 590 'notify-send -u critical \"Idling in 10 seconds!\"'"
"timeout 591 'notify-send -u critical \"Idling in 9 seconds!\"'"
"timeout 592 'notify-send -u critical \"Idling in 8 seconds!\"'"
"timeout 593 'notify-send -u critical \"Idling in 7 seconds!\"'"
"timeout 594 'notify-send -u critical \"Idling in 6 seconds!\"'"
"timeout 595 'notify-send -u critical \"Idling in 5 seconds!\"'"
"timeout 596 'notify-send -u critical \"Idling in 4 seconds!\"'"
"timeout 597 'notify-send -u critical \"Idling in 3 seconds!\"'"
"timeout 598 'notify-send -u critical \"Idling in 2 seconds!\"'"
"timeout 599 'notify-send -u critical \"Idling in 1 second!\"'"
"timeout 600 'swaylock -f'"
"timeout 600 'hyprctl dispatch dpms off' resume 'hyprctl dispatch dpms on'"
])
]; ];
env = [ env = [
@ -134,7 +102,7 @@ in {
}; };
decoration = { decoration = {
rounding = 3; rounding = 5;
/* /*
blur = "no"; blur = "no";
@ -231,7 +199,7 @@ in {
# Scroll through existing workspaces with mod + scroll # Scroll through existing workspaces with mod + scroll
"$mod, mouse_down, workspace, e+1" "$mod, mouse_down, workspace, e+1"
"$mod, mouse_up, workspace, e-1" "$mod, mouse_up, workspace, e-1"
"CTRL SHIFT $mod, L, exec, swaylock" "CTRL SHIFT $mod, L, exec, hyprlock"
"$mod CTRL, space, exec, makoctl dismiss" "$mod CTRL, space, exec, makoctl dismiss"
"$mod SHIFT CTRL, space, exec, makoctl restore" "$mod SHIFT CTRL, space, exec, makoctl restore"
"$mod SHIFT, space, exec, makoctl invoke default" "$mod SHIFT, space, exec, makoctl invoke default"
@ -296,4 +264,157 @@ in {
windowrulev2 = nofocus, class:^(xwaylandvideobridge)$ windowrulev2 = nofocus, class:^(xwaylandvideobridge)$
''; '';
}; };
programs.hyprlock = {
enable = true;
settings = {
# docs: https://wiki.hyprland.org/Hypr-Ecosystem/hyprlock
general = {
grace = 0;
no_face_out = true;
};
input-field = [
{
monitor = "";
fade_on_empty = false;
placeholder_text = "Locked";
rounding = 5;
font_size = 20;
font_color = "rgba(255, 255, 255, 1.0)";
inner_color = "rgba(31, 31, 47, 0.95)";
outer_color = "0xff74c7ec 0xff74c7ec 45deg";
outline_thickness = 3;
position = "0, -200";
dots_size = 0.1;
size = "300 75";
font_family = "IosevkaLyteTerm";
shadow_passes = 3;
shadow_size = 8;
shadow_color = "rgba(0, 0, 0, 1.0)";
shadow_boost = 0.8;
}
];
background = [
{
path = "~/.wallpaper";
blur_passes = 2;
}
];
label = [
{
monitor = "";
font_size = 64;
halign = "center";
valign = "center";
text_align = "center";
# rotate = 10;
position = "0, 200";
font_family = "IosevkaLyteTerm";
text = ''Locked for <span foreground="##74c7ec">$USER</span>'';
shadow_passes = 1;
shadow_size = 8;
shadow_color = "rgba(0, 0, 0, 1.0)";
shadow_boost = 0.5;
}
{
monitor = "";
font_size = 20;
halign = "center";
valign = "center";
text_align = "center";
color = "rgba(255, 255, 255, 0.5)";
position = "0 120";
font_family = "IosevkaLyteTerm";
text = "cmd[update:1000] date '+%a %b %d %H:%M:%S'";
shadow_passes = 3;
shadow_size = 1;
shadow_color = "rgba(0, 0, 0, 1.0)";
shadow_boost = 1.0;
}
{
monitor = "";
font_size = 200;
halign = "center";
valign = "center";
text_align = "center";
color = "rgba(220, 240, 255, 0.8)";
position = "0 500";
font_family = "NerdFontSymbolsOnly";
text = "󰍁";
shadow_passes = 3;
shadow_size = 1;
shadow_color = "rgba(0, 0, 0, 1.0)";
shadow_boost = 1.0;
}
];
};
};
services.hypridle = let
secondsPerMinute = 60;
lockSeconds = 10 * secondsPerMinute;
in {
enable = true;
settings = {
general = {
after_sleep_cmd = "hyprctl dispatch dpms on";
before_sleep_cmd = "loginctl lock-session";
ignore_dbus_inhibit = false;
lock_cmd = "pidof hyprlock || hyprlock";
};
listener = [
{
timeout = lockSeconds - 300;
on-timeout = ''notify-send "Auto-locking in 5 minutes"'';
on-resume = ''notify-send "Auto-locking cancelled"'';
}
{
timeout = lockSeconds - 180;
on-timeout = ''notify-send "Auto-locking in 3 minutes"'';
}
{
timeout = lockSeconds - 120;
on-timeout = ''notify-send "Auto-locking in 2 minutes"'';
}
{
timeout = lockSeconds - 60;
on-timeout = ''notify-send "Auto-locking in 1 minute"'';
}
{
timeout = lockSeconds - 30;
on-timeout = ''notify-send "Auto-locking in 30 seconds"'';
}
{
timeout = lockSeconds - 10;
on-timeout = ''notify-send -u critical "Auto-locking in 10 seconds"'';
}
{
timeout = lockSeconds;
on-timeout = ''loginctl lock-session'';
}
{
timeout = lockSeconds + 5;
on-timeout = ''hyprctl dispatch dpms off'';
on-resume = ''hyprctl dispatch dpms on'';
}
];
};
};
} }

View file

@ -2,7 +2,6 @@
style, style,
lib, lib,
config, config,
pkgs,
... ...
}: { }: {
programs.foot = { programs.foot = {
@ -20,57 +19,6 @@
}; };
}; };
home.file."${config.xdg.configHome}/mako/config" = {
enable = true;
text = with style.colors.withHashPrefix; ''
border-size=2
border-radius=5
padding=10,15
max-visible=5
default-timeout=15000
font=Symbols Nerd Font ${toString style.font.size},${style.font.name} ${toString style.font.size}
anchor=top-right
on-notify=exec ${pkgs.mpv}/bin/mpv --volume=50 ~/.notify.wav
actions=1
icons=1
width=400
height=150
background-color=${bg}DD
text-color=${text}
border-color=${primary}
progress-color=${primary}
[urgency=high]
border-color=${urgent}
[urgency=high]
background-color=${urgent}EE
border-color=${urgent}
text-color=${bg}
'';
};
home.file."${config.xdg.configHome}/tofi/config" = {
enable = true;
text = ''
font = ${pkgs.iosevkaLyteTerm}/share/fonts/truetype/IosevkaLyteTerm-regular.ttf
font-size = 12
text-color = #f8f8f8
prompt-color = #f38ba8
selection-color = #66d9ef
background-color = #1e1e2e
outline-width = 0
border-width = 1
border-color = #66d9ef
width = 640
height = 400
fuzzy-match = true
'';
};
wayland.windowManager.sway = { wayland.windowManager.sway = {
/* /*
TODO: TODO:

View file

@ -294,6 +294,20 @@ in
# TODO: nixify this # TODO: nixify this
}; };
services.hypridle = let
secondsPerMinute = 60;
lockSeconds = 10 * secondsPerMinute;
in {
settings = {
listener = [
{
timeout = lockSeconds + 55;
on-timeout = ''systemctl suspend'';
}
];
};
};
wayland.windowManager.hyprland = { wayland.windowManager.hyprland = {
settings = { settings = {
exec-once = [ exec-once = [