{ pkgs, lib, config, ... }: let # lockColors = with config.lib.stylix.colors.withHashtag; { a = base00; b = base01; d = base00; }; # Black or White, depending on current theme # lockColors = with config.lib.stylix.colors.withHashtag; { a = base0A; b = base0B; d = base00; }; # Green + Yellow lockColors = { a = "#82a401"; b = "#466c01"; d = "#648901"; }; # Old lockSvg = pkgs.writeText "lock.svg" '' ''; lockPng = pkgs.runCommand "lock.png" { } "${pkgs.imagemagick}/bin/convert ${lockSvg} $out"; mod = config.xsession.windowManager.i3.config.modifier; in { config = lib.mkIf config.frogeye.desktop.xorg { home.packages = with pkgs; [ (pkgs.writeShellApplication { name = "xlock"; text = '' ${config.frogeye.hooks.lock} # TODO Maybe we could have a terminal lock? With vlock. # TODO Does that work for all DMs? # TODO Might want to use i3lock on NixOS configs still? if ! ${pkgs.lightdm}/bin/dm-tool lock then if [ -d ${config.xdg.cacheHome}/lockpatterns ] then pattern=$(${pkgs.findutils} ${config.xdg.cacheHome}/lockpatterns | sort -R | head -1) else pattern=${lockPng} fi revert() { ${pkgs.xorg.xset}/bin/xset dpms 0 0 0 } trap revert SIGHUP SIGINT SIGTERM ${pkgs.xorg.xset}/bin/xset dpms 5 5 5 ${pkgs.i3lock}/bin/i3lock --nofork --color ${builtins.substring 1 6 lockColors.d} --image="$pattern" --tiling --ignore-empty-password revert fi ''; }) ]; xsession.windowManager.i3.config = { keybindings = { # Screen off commands "${mod}+F1" = "exec --no-startup-id ${pkgs.bash}/bin/sh -c \"${pkgs.coreutils}/bin/sleep .25 && ${pkgs.xorg.xset}/bin/xset dpms force off\""; # TODO --release? "${mod}+F4" = "exec --no-startup-id ${pkgs.xautolock}/bin/xautolock -disable"; "${mod}+F5" = "exec --no-startup-id ${pkgs.xautolock}/bin/xautolock -enable"; }; startup = [ # Lock screen after 10 minutes { notification = false; command = "${pkgs.xautolock}/bin/xautolock -time 10 -locker '${pkgs.xorg.xset}/bin/xset dpms force standby' -killtime 1 -killer xlock"; } # TODO There's a services.screen-locker.xautolock but not sure it can match the above command ]; }; }; }