Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

desktop: set hyprland to use hypridle + hyprlock #170

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeManagerModules/desktop/hyprland/settings.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ in {
[
''$mod,M,exec,${lib.getExe config.programs.rofi.package} -show power-menu -modi "power-menu:${lib.getExe pkgs.rofi-power-menu} --choices=logout/lockscreen/suspend/shutdown/reboot"''
",PRINT,exec,${helpers.screenshot}"
"$mod CTRL,L,exec,${lib.getExe pkgs.swaylock}"
"$mod CTRL,L,exec,${lib.getExe' pkgs.systemd "loginctl"} lock-session"
"$mod SHIFT,backslash,togglesplit"
"$mod SHIFT,comma,exec,${lib.getExe pkgs.hyprnome} --previous --move"
"$mod SHIFT,G,togglegroup"
Expand Down
2 changes: 1 addition & 1 deletion homeManagerModules/desktop/sway/settings.nix
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ in {
"${modifier}+B" = "exec ${lib.getExe cfg.defaultApps.webBrowser}";
"${modifier}+C" = "kill";
"${modifier}+Comma" = "workspace prev";
"${modifier}+Control+L" = "exec ${lib.getExe pkgs.swaylock}";
"${modifier}+Control+L" = "exec ${lib.getExe' pkgs.systemd "loginctl"} lock-session";
"${modifier}+E" = "exec ${lib.getExe cfg.defaultApps.editor}";
"${modifier}+F" = "exec ${lib.getExe cfg.defaultApps.fileManager}";
"${modifier}+F11" = "exec pkill -SIGUSR1 waybar"; # Show/hide waybar
Expand Down
3 changes: 2 additions & 1 deletion homeManagerModules/desktop/wayland/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
};

services = {
hypridle.enable = lib.mkDefault config.ar.home.desktop.hyprland.enable;
mako.enable = lib.mkDefault true;
pipewire-inhibit.enable = lib.mkDefault true;
swayidle.enable = lib.mkDefault true;
swayidle.enable = lib.mkDefault config.ar.home.desktop.sway.enable;
swayosd.enable = lib.mkDefault true;
waybar.enable = lib.mkDefault true;
};
Expand Down
1 change: 1 addition & 0 deletions homeManagerModules/options.nix
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ in {
};

gammastep.enable = lib.mkEnableOption "Gammastep redshift daemon.";
hypridle.enable = lib.mkEnableOption "Hypridle idle daemon.";
mako.enable = lib.mkEnableOption "Mako notification daemon.";

mpd = {
Expand Down
1 change: 1 addition & 0 deletions homeManagerModules/services/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
imports = [
./easyeffects
./gammastep
./hypridle
./mako
./mpd
./pipewire-inhibit
Expand Down
81 changes: 81 additions & 0 deletions homeManagerModules/services/hypridle/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
config,
lib,
pkgs,
...
}: let
cfg = config.ar.home;
in {
config = lib.mkIf cfg.services.hypridle.enable {
programs.hyprlock.enable = true;

services.hypridle = {
enable = true;

settings = {
general = {
after_sleep_cmd = "hyprctl dispatch dpms on";
lock_cmd = "hyprlock";
before_sleep_cmd = "hyprlock --immediate --no-fade-in";
};

listener =
[
{
timeout = 30;
on-timeout = "brightnessctl -sd chromeos::kbd_backlight set 0";
on-resume = "brightnessctl -rd chromeos::kbd_backlight";
}
{
timeout = 120;
on-timeout = "brightnessctl -s set 10";
on-resume = "brightnessctl -r";
}
]
++ lib.optional (!cfg.desktop.autoSuspend) {
timeout = 600;
on-timeout = "hyprlock";
}
++ lib.optional cfg.desktop.autoSuspend {
timeout = 600;
command = "systemctl suspend";
}
++ lib.optional
(!cfg.desktop.autoSuspend) {
timeout = 600;
on-timeout = "hyprlock";
}
++ lib.optional (!cfg.desktop.autoSuspend && cfg.desktop.hyprland.enable)
{
timeout = 630;
on-timeout = "hyprctl dispatch dpms off";
on-resume = "hyprctl dispatch dpms on";
};
};
};

systemd.user.services.hypridle = {
Install.WantedBy = lib.mkForce (lib.optional (cfg.desktop.hyprland.enable) "hyprland-session.target");

Service = {
Environment = lib.mkForce [
"PATH=${
lib.makeBinPath (
(with pkgs; [
bash
brightnessctl
coreutils
hyprlock
systemd
])
++ lib.optional (cfg.desktop.hyprland.enable) config.wayland.windowManager.hyprland.package
)
}"
];
Restart = lib.mkForce "no";
};

Unit.BindsTo = lib.optional (cfg.desktop.hyprland.enable) "hyprland-session.target";
};
};
}
21 changes: 7 additions & 14 deletions homeManagerModules/services/swayidle/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ in {
enable = true;

events = [
{
event = "before-sleep";
command = "playerctl pause";
}
{
event = "before-sleep";
command = "swaylock && sleep 2";
Expand All @@ -27,6 +23,11 @@ in {

timeouts =
[
{
timeout = 30;
command = "brightnessctl -sd chromeos::kbd_backlight set 0";
resumeCommand = "brightnessctl -rd chromeos::kbd_backlight";
}
{
timeout = 120;
command = "brightnessctl -s set 10";
Expand All @@ -42,12 +43,6 @@ in {
timeout = 600;
command = "swaylock";
}
++ lib.optional (!cfg.desktop.autoSuspend && cfg.desktop.hyprland.enable)
{
timeout = 630;
command = "hyprctl dispatch dpms off";
resumeCommand = "hyprctl dispatch dpms on";
}
++ lib.optional (!cfg.desktop.autoSuspend && cfg.desktop.sway.enable)
{
timeout = 630;
Expand All @@ -57,7 +52,7 @@ in {
};

systemd.user.services.swayidle = {
Install.WantedBy = lib.mkForce (lib.optional (cfg.desktop.hyprland.enable) "hyprland-session.target" ++ lib.optional (cfg.desktop.sway.enable) "sway-session.target");
Install.WantedBy = lib.mkForce (lib.optional (cfg.desktop.sway.enable) "sway-session.target");

Service = {
Environment = lib.mkForce [
Expand All @@ -66,18 +61,16 @@ in {
bash
brightnessctl
coreutils
playerctl
swaylock
systemd
])
++ lib.optional (cfg.desktop.hyprland.enable) config.wayland.windowManager.hyprland.package
++ lib.optional (cfg.desktop.sway.enable) config.wayland.windowManager.sway.package)
}"
];
Restart = lib.mkForce "no";
};

Unit.BindsTo = lib.optional (cfg.desktop.hyprland.enable) "hyprland-session.target" ++ lib.optional (cfg.desktop.sway.enable) "sway-session.target";
Unit.BindsTo = lib.optional (cfg.desktop.sway.enable) "sway-session.target";
};
};
}