diff --git a/home-manager/linux/default.nix b/home-manager/linux/default.nix index cf0914f..b3548d0 100644 --- a/home-manager/linux/default.nix +++ b/home-manager/linux/default.nix @@ -53,6 +53,18 @@ with nLib; { description = "Targets to install desktop services to"; default = [ "hyprland-session.target" ]; }; + swaylock = { + package = mkOption { + description = "Swaylock package to use"; + default = + inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.swaylock-effects; + }; + command = mkOption { + description = "Swaylock package to use"; + default = '' + --screenshots --grace 30 --indicator --clock --timestr "%-I:%M:%S %p" --datestr "%A %Y-%M-%d" --effect-blur 20x3''; + }; + }; }; }; # Linux specific programs diff --git a/home-manager/linux/programs/desktop/locking.nix b/home-manager/linux/programs/desktop/locking.nix new file mode 100644 index 0000000..e1ac2f1 --- /dev/null +++ b/home-manager/linux/programs/desktop/locking.nix @@ -0,0 +1,35 @@ +{ config, lib, pkgs, ... }: +let + swaylock-package = config.nathan.config.desktop.swaylock.package; + swaylock-command = config.nathan.config.desktop.swaylock.command; + targets = config.nathan.config.desktop.targets; +in lib.mkMerge [ + (lib.mkIf config.nathan.programs.hyprland.enable { + wayland.windowManager.hyprland.extraConfig = '' + bind = SUPER, Z, exec, ${swaylock-package}/bin/swaylock ${swaylock-command} + ''; + }) + ({ + home.packages = with pkgs; [ swaylock-package swayidle ]; + + services.swayidle = { + enable = true; + timeouts = [ + # Lock the screen after 5 minutes of inactivity + { + timeout = 300; + command = "${swaylock-package}/bin/swaylock ${ + builtins.replaceStrings [ "%" ] [ "%%" ] swaylock-command + }"; + } + # Turn off the displays after 10 minutes of inactivity + { + timeout = 600; + command = "hyprctl dispatch dpms off"; + resumeCommand = "hyprctl dispatch dpms on"; + } + ]; + }; + systemd.user.services.swayidle = { Install = { WantedBy = targets; }; }; + }) +] diff --git a/home-manager/linux/programs/hyprland.nix b/home-manager/linux/programs/hyprland.nix index 2fd593b..3035c59 100644 --- a/home-manager/linux/programs/hyprland.nix +++ b/home-manager/linux/programs/hyprland.nix @@ -1,14 +1,9 @@ { config, lib, pkgs, inputs, ... }@args: let nathan = config.nathan; in with lib; { - imports = [ ./desktop/waybar.nix ]; + imports = [ ./desktop/waybar.nix ./desktop/locking.nix ]; config = mkIf nathan.programs.hyprland.enable (let - swaylock-package = - inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.swaylock-effects; - swaylock-command = '' - ${swaylock-package}/bin/swaylock --screenshots --grace 30 --indicator --clock --timestr "%-I:%M:%S %p" --datestr "%A %Y-%M-%d" --effect-blur 20x3''; - # fuzzel-command = config.nathan.config.desktop.fuzzel-command; - fuzzel-command = ""; + fuzzel-command = config.nathan.config.desktop.fuzzel-command; notif-package = inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.swaynotificationcenter; shortcuts = inputs.self.packages.${pkgs.system}.shortcuts; @@ -16,10 +11,8 @@ in with lib; { home.packages = with pkgs; [ # General killall - # Locking and display management + # Display management wdisplays - swaylock-package - swayidle # Clipboard wl-clipboard cliphist @@ -145,7 +138,6 @@ in with lib; { bind = $mainMod, R, exec, ${fuzzel-command} --prompt='❯ ' bind = $mainMod, P, pseudo, # dwindle bind = $mainMod, B, togglesplit, # dwindle - bind = $mainMod, Z, exec, ${swaylock-command} # Move focus with mainMod + arrow keys bind = $mainMod, H, movefocus, l @@ -387,28 +379,6 @@ in with lib; { Install = { WantedBy = [ "hyprland-session.target" ]; }; }; ######################### - ## Swayidle - ######################### - services.swayidle = { - enable = true; - timeouts = [ - # Lock the screen after 5 minutes of inactivity - { - timeout = 300; - command = builtins.replaceStrings [ "%" ] [ "%%" ] swaylock-command; - } - # Turn off the displays after 10 minutes of inactivity - { - timeout = 600; - command = "hyprctl dispatch dpms off"; - resumeCommand = "hyprctl dispatch dpms on"; - } - ]; - }; - systemd.user.services.swayidle = { - Install = { WantedBy = [ "hyprland-session.target" ]; }; - }; - ######################### ## EasyEffects ######################### services.easyeffects.enable = true;