Skip to content

Commit

Permalink
add swayidle
Browse files Browse the repository at this point in the history
  • Loading branch information
otosky committed Sep 21, 2024
1 parent 995ac45 commit 7a9b39e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions homes/_modules/desktop/common/wayland-wm/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{pkgs, ...}: {
imports = [
./swaylock.nix
./swayidle.nix
./waybar.nix
./wofi.nix
./swaync.nix
Expand Down
45 changes: 45 additions & 0 deletions homes/_modules/desktop/common/wayland-wm/swayidle.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
pkgs,
lib,
config,
...
}: let
swaylock = "${config.programs.swaylock.package}/bin/swaylock";
hyprctl = "${config.wayland.windowManager.hyprland.package}/bin/hyprctl";
lockTime = 1 * 60; # TODO: configurable desktop (10 min)/laptop (4 min)
in {
services.swayidle = {
enable = true;
systemdTarget = "graphical-session.target";
extraArgs = [
"-d"
];
timeouts =
# Lock screen
[
{
timeout = lockTime;
command = "${swaylock} -defF";
}
{
timeout = 180;
command = "${hyprctl} dispatch dpms off";
resumeCommand = "${hyprctl} dispatch dpms on";
}
];
events = [
{
event = "lock";
command = "${swaylock} -defF";
}
{
event = "after-resume";
command = "${hyprctl} dispatch dpms on";
}
{
event = "before-sleep";
command = "${swaylock} -defF";
}
];
};
}
1 change: 1 addition & 0 deletions homes/_modules/desktop/hyprland.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ in {
package = hyprland;
systemd = {
enable = true;
variables = ["--all"];
# Same as default, but stop graphical-session too
extraCommands = lib.mkBefore [
"systemctl --user stop graphical-session.target"
Expand Down

0 comments on commit 7a9b39e

Please sign in to comment.