NixOS-Config/modules/home/sway/swaylock/default.nix

65 lines
1.6 KiB
Nix
Raw Normal View History

2024-10-15 02:40:43 -04:00
{ pkgs, config, ... }:
2024-10-09 03:36:08 -04:00
let
2024-09-23 16:22:01 -04:00
swayLock = pkgs.writeScriptBin "swaylock" ''
2024-08-24 22:16:51 -04:00
# Set the lock script
lockscript() {
BLANK='#00000000'
CLEAR='#FFFFFF22'
2024-10-15 02:40:43 -04:00
DEFAULT='#${config.look.colors.prime}FF'
2024-08-24 22:16:51 -04:00
TEXT='#FFFFFFFF'
2024-10-15 02:40:43 -04:00
WRONG='#${config.look.colors.split}FF'
VERIFYING='#${config.look.colors.accent}FF'
2024-08-24 22:16:51 -04:00
${pkgs.swaylock-effects}/bin/swaylock -f -e \
--key-hl-color=$VERIFYING \
--bs-hl-color=$WRONG \
\
--ring-clear-color=$CLEAR \
--ring-ver-color=$VERIFYING \
--ring-wrong-color=$WRONG \
--ring-color=$DEFAULT \
--ring-clear-color=$VERIFYING \
\
--inside-color=$CLEAR \
--inside-ver-color=$CLEAR \
--inside-wrong-color=$CLEAR \
--inside-clear-color=$CLEAR \
\
--text-color=$TEXT \
--text-clear-color=$TEXT \
--text-ver-color=$TEXT \
--text-caps-lock-color=$TEXT \
--text-wrong-color=$TEXT \
\
--indicator \
--indicator-radius=80 \
--image=~/.wallpapers/lock.png \
--clock \
2024-10-15 02:40:43 -04:00
--font=${config.look.fonts.main} \
2024-08-24 22:16:51 -04:00
--font-size=30 \
--timestr="%I:%M%p" \
--datestr="%a %b %d %Y"
}
# Handle whether to lock or sleep
if [ "$1" == "--sleep" ]; then
lockscript &
exec ${pkgs.swayidle}/bin/swayidle -w \
timeout 1 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"; pkill -9 swayidle'
else
lockscript
fi
'';
in {
# Enable Sway and write some scripts
home.packages = with pkgs; [
swayLock
];
# Enable Sway lock on startup
wayland.windowManager.sway.config.startup = [
{command = "swaylock";}
];
2024-08-24 22:16:51 -04:00
}