From 6551644cedd8cb00ed26183087950ab4947729c3 Mon Sep 17 00:00:00 2001 From: Erwin Boskma Date: Tue, 7 Jan 2025 16:48:39 +0100 Subject: [PATCH] Add swaylock module and update swaylock calls --- home-manager/modules/river/default.nix | 15 +++--- home-manager/modules/river/powermenu.sh | 3 +- home-manager/modules/sway/default.nix | 30 +++++------ home-manager/modules/sway/powermenu.sh | 3 +- home-manager/modules/swaylock/default.nix | 65 +++++++++++++++++++++++ users/erwin/home.nix | 9 +++- users/erwin/work.nix | 2 +- 7 files changed, 100 insertions(+), 27 deletions(-) create mode 100644 home-manager/modules/swaylock/default.nix diff --git a/home-manager/modules/river/default.nix b/home-manager/modules/river/default.nix index e0954b9..a8250bb 100644 --- a/home-manager/modules/river/default.nix +++ b/home-manager/modules/river/default.nix @@ -9,11 +9,12 @@ let cfg = config.eboskma.programs.river; mod = "Mod4"; - lockcmd = "${pkgs.swaylock}/bin/swaylock --ignore-empty-password --daemonize --show-failed-attempts --indicator-caps-lock --image ${cfg.wallpaper} --scaling fill"; + # lockcmd = "${pkgs.swaylock}/bin/swaylock --ignore-empty-password --daemonize --show-failed-attempts --indicator-caps-lock --image ${cfg.wallpaper} --scaling fill"; + lockcmd = "${lib.getExe pkgs.swaylock}"; rofiPower = pkgs.writeShellScriptBin "rofi-power" ( - builtins.replaceStrings [ "{WALLPAPER}" ] [ (builtins.toString cfg.wallpaper) ] ( - builtins.readFile ./powermenu.sh - ) + # builtins.replaceStrings [ "{WALLPAPER}" ] [ (builtins.toString cfg.wallpaper) ] ( + builtins.readFile ./powermenu.sh + # ) ); menu = "${config.programs.anyrun.package}/bin/anyrun"; @@ -136,10 +137,12 @@ in "None XF86AudioMute" = "spawn '${pkgs.pamedia}/bin/pamedia mute'"; "None XF86Calculator" = "spawn ${pkgs.gnome-calculator}/bin/gnome-calculator"; - "${mod} c" = mkIf config.eboskma.programs.emacs.enable "spawn '${config.eboskma.programs.emacs.package}/bin/emacsclient -c'"; + "${mod} c" = + mkIf config.eboskma.programs.emacs.enable "spawn '${config.eboskma.programs.emacs.package}/bin/emacsclient -c'"; "${mod} d" = "spawn '${pkgs.swaynotificationcenter}/bin/swaync-client --toggle-panel --skip-wait'"; - "${mod}+Shift d" = "spawn '${pkgs.swaynotificationcenter}/bin/swaync-client --toggle-dnd --skip-wait'"; + "${mod}+Shift d" = + "spawn '${pkgs.swaynotificationcenter}/bin/swaync-client --toggle-dnd --skip-wait'"; "${mod}+Shift f" = "spawn ${rofiPower}/bin/rofi-power"; diff --git a/home-manager/modules/river/powermenu.sh b/home-manager/modules/river/powermenu.sh index e527589..235f64e 100755 --- a/home-manager/modules/river/powermenu.sh +++ b/home-manager/modules/river/powermenu.sh @@ -23,7 +23,8 @@ exit_wm="󰗼" # Icon: exit_to_app # Variable passed to rofi options="${shutdown}\n${reboot}\n${lock}\n${hibernate}\n${exit_wm}" uptime=$(uptime | awk '{print $1}' || true) -lockcmd="swaylock --ignore-empty-password --daemonize --show-failed-attempts --indicator-caps-lock --image {WALLPAPER} --scaling fill" +# lockcmd="swaylock --ignore-empty-password --daemonize --show-failed-attempts --indicator-caps-lock --image {WALLPAPER} --scaling fill" +lockcmd="swaylock" chosen="$(echo -e "${options}" | rofi -theme power -p "Uptime: ${uptime}" -dmenu -selected-row 2)" diff --git a/home-manager/modules/sway/default.nix b/home-manager/modules/sway/default.nix index 5eec770..2ff95bd 100644 --- a/home-manager/modules/sway/default.nix +++ b/home-manager/modules/sway/default.nix @@ -8,11 +8,12 @@ with lib; let cfg = config.eboskma.programs.sway; mod = "Mod4"; - swaylockcmd = "${pkgs.swaylock}/bin/swaylock --ignore-empty-password --daemonize --show-failed-attempts --indicator-caps-lock --image ${cfg.lock-wallpaper} --scaling fill"; + # swaylockcmd = "${pkgs.swaylock}/bin/swaylock --ignore-empty-password --daemonize --show-failed-attempts --indicator-caps-lock --image ${cfg.lock-wallpaper} --scaling fill"; + swaylockcmd = "${lib.getExe pkgs.swaylock}"; rofiPower = pkgs.writeShellScriptBin "rofi-power" ( - builtins.replaceStrings [ "{WALLPAPER}" ] [ (builtins.toString cfg.lock-wallpaper) ] ( - builtins.readFile ./powermenu.sh - ) + # builtins.replaceStrings [ "{WALLPAPER}" ] [ (builtins.toString cfg.lock-wallpaper) ] ( + builtins.readFile ./powermenu.sh + # ) ); in { @@ -23,10 +24,10 @@ in default = true; }; - lock-wallpaper = mkOption { - description = "Wallpaper to use for the lockscreen"; - type = types.path; - }; + # lock-wallpaper = mkOption { + # description = "Wallpaper to use for the lockscreen"; + # type = types.path; + # }; terminal = mkOption { description = "Default terminal to run"; type = types.str; @@ -152,7 +153,10 @@ in right = "o"; floating = { - criteria = [ { app_id = "gnome-calculator"; } ]; + criteria = [ + { app_id = "gnome-calculator"; } + { app_id = "dev.deedles.Trayscale"; } + ]; modifier = mod; }; @@ -379,13 +383,5 @@ in }; }; - systemd.user = { - targets.tray = { - Unit = { - Description = "Home Manager System Tray"; - Requires = [ "sway-session-pre.target" ]; - }; - }; - }; }; } diff --git a/home-manager/modules/sway/powermenu.sh b/home-manager/modules/sway/powermenu.sh index feca699..80713ce 100755 --- a/home-manager/modules/sway/powermenu.sh +++ b/home-manager/modules/sway/powermenu.sh @@ -23,7 +23,8 @@ exit_wm="󰗼" # Icon: exit_to_app # Variable passed to rofi options="${shutdown}\n${reboot}\n${lock}\n${hibernate}\n${exit_wm}" uptime=$(uptime | awk '{print $1}' || true) -lockcmd="swaylock --ignore-empty-password --daemonize --show-failed-attempts --indicator-caps-lock --image {WALLPAPER} --scaling fill" +# lockcmd="swaylock --ignore-empty-password --daemonize --show-failed-attempts --indicator-caps-lock --image {WALLPAPER} --scaling fill" +lockcmd="swaylock" chosen="$(echo -e "${options}" | rofi -theme power -p "Uptime: ${uptime}" -dmenu -selected-row 2)" diff --git a/home-manager/modules/swaylock/default.nix b/home-manager/modules/swaylock/default.nix new file mode 100644 index 0000000..fe34362 --- /dev/null +++ b/home-manager/modules/swaylock/default.nix @@ -0,0 +1,65 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +let + cfg = config.eboskma.programs.swaylock; +in +{ + options.eboskma.programs.swaylock = { + enable = mkEnableOption "swaylock"; + wallpaper = mkOption { + description = "Wallpaper to use for the lockscreen"; + type = types.nullOr types.path; + default = null; + }; + }; + + config = mkIf cfg.enable { + programs.swaylock = { + enable = true; + settings = { + ignore-empty-password = true; + daemonize = true; + show-failed-attempts = true; + indicator-caps-lock = true; + image = mkIf (cfg.wallpaper != null) cfg.wallpaper; + scaling = "fill"; + + # Catppuccin Mocha + color = "1e1e2e"; + bs-hl-color = "f5e0dc"; + caps-lock-bs-hl-color = "f5e0dc"; + caps-lock-key-hl-color = "a6e3a1"; + inside-color = "00000000"; + inside-clear-color = "00000000"; + inside-caps-lock-color = "00000000"; + inside-ver-color = "00000000"; + inside-wrong-color = "00000000"; + key-hl-color = "a6e3a1"; + layout-bg-color = "00000000"; + layout-border-color = "00000000"; + layout-text-color = "cdd6f4"; + line-color = "00000000"; + line-clear-color = "00000000"; + line-caps-lock-color = "00000000"; + line-ver-color = "00000000"; + line-wrong-color = "00000000"; + ring-color = "b4befe"; + ring-clear-color = "f5e0dc"; + ring-caps-lock-color = "fab387"; + ring-ver-color = "89b4fa"; + ring-wrong-color = "eba0ac"; + separator-color = "00000000"; + text-color = "cdd6f4"; + text-clear-color = "f5e0dc"; + text-caps-lock-color = "fab387"; + text-ver-color = "89b4fa"; + text-wrong-color = "eba0ac"; + }; + }; + }; +} diff --git a/users/erwin/home.nix b/users/erwin/home.nix index 25e2812..95e4d55 100644 --- a/users/erwin/home.nix +++ b/users/erwin/home.nix @@ -226,7 +226,6 @@ in enable = true; package = pkgs.swayfx; terminal = lib.getExe pkgs.ghostty; - lock-wallpaper = "${homeCfg.home.homeDirectory}/.wallpapers/river-2560.png"; output = { "DP-2" = { bg = "${homeCfg.home.homeDirectory}/.wallpapers/river-2560.png fill"; @@ -249,6 +248,10 @@ in }; }; }; + swaylock = { + enable = true; + # wallpaper = "${homeCfg.home.homeDirectory}/.wallpapers/river-2560.png"; + }; swaynotificationcenter.enable = true; tea = { enable = true; @@ -531,6 +534,10 @@ in }; playerctld.enable = true; + + trayscale = { + enable = true; + }; }; imports = diff --git a/users/erwin/work.nix b/users/erwin/work.nix index b3599fb..bde0755 100644 --- a/users/erwin/work.nix +++ b/users/erwin/work.nix @@ -214,7 +214,6 @@ in package = pkgs.sway; terminal = lib.getExe pkgs.ghostty; swayidle = false; - lock-wallpaper = "${homeCfg.home.homeDirectory}/.wallpapers/river-3840.png"; output = { "DP-1" = { bg = "${../../wallpapers/river-3840.png} fill"; @@ -252,6 +251,7 @@ in "--locked Mod4+Ctrl+r" = "output DP-1 disable, output DP-3 disable, output HDMI-A-1 enable"; }; }; + swaylock.enable = true; swaynotificationcenter.enable = true; tmux.enable = true; waybar = {