diff --git a/home-manager/modules/lightlocker/default.nix b/home-manager/modules/lightlocker/default.nix deleted file mode 100644 index cdcd17f..0000000 --- a/home-manager/modules/lightlocker/default.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ pkgs, lib, ... }: -{ - systemd.user.services.light-locker = { - Unit = { - Description = "LightLocker screen locker"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; - }; - - Service = { - Type = "simple"; - ExecStart = ''/bin/sh -l -c "${lib.getExe pkgs.lightlocker} --lock-on-suspend"''; - }; - - Install = { WantedBy = [ "graphical-session.target" ]; }; - }; -} diff --git a/home-manager/modules/picom/picom.conf b/home-manager/modules/picom/picom.conf index b783144..d2a21db 100644 --- a/home-manager/modules/picom/picom.conf +++ b/home-manager/modules/picom/picom.conf @@ -195,7 +195,7 @@ dbe = false; # Unredirect all windows if a full-screen opaque window is detected, to maximize performance for full-screen windows, like games. # Known to cause flickering when redirecting/unredirecting windows. -unredir-if-possible = false; +unredir-if-possible = true; # Specify a list of conditions of windows that should always be considered focused. focus-exclude = [ ]; diff --git a/home-manager/modules/profiles/workstation.nix b/home-manager/modules/profiles/workstation.nix index b844786..8a5e35d 100644 --- a/home-manager/modules/profiles/workstation.nix +++ b/home-manager/modules/profiles/workstation.nix @@ -32,13 +32,13 @@ in ../picom ../dunst ../keynav - ../lightlocker ../bash ../emacs ../xmonad ../pantalaimon.nix ../ssh.nix ../wallpaper + ../screenlocker ]; programs.librewolf = { diff --git a/home-manager/modules/screenlocker/default.nix b/home-manager/modules/screenlocker/default.nix new file mode 100644 index 0000000..9f6337c --- /dev/null +++ b/home-manager/modules/screenlocker/default.nix @@ -0,0 +1,54 @@ +{ config, pkgs, lib, ... }: +let + inherit (lib) + singleton + getExe + makeBinPath; + + locker = pkgs.writeShellScript "i3lock-dynamic-image" '' + export PATH=${makeBinPath (with pkgs; [ gnugrep coreutils xorg.xdpyinfo imagemagick i3lock ])}:$PATH + + WALLPAPER_CACHE="$HOME/.local/tmp/wallpaper_cache" + + mkdir -p $WALLPAPER_CACHE + + SCREEN_RESOLUTION="$(xdpyinfo | grep dimensions | cut -d' ' -f7)" + IMAGEFILE="$WALLPAPER_CACHE/$(sha256sum $HOME/.config/wallpaper | tr -s ' ' | cut -f 1 -d' ').png" + I3LOCK="i3lock -d -c 000000 -i $IMAGEFILE" + + if ! [[ -e "$IMAGEFILE" ]] + then + convert "$HOME/.config/wallpaper" -gravity Center -background "#000000" -extent "$SCREEN_RESOLUTION" "$IMAGEFILE" + fi + + if [[ -e /dev/fd/''${XSS_SLEEP_LOCK_FD:--1} ]]; then + kill_i3lock() { + pkill -xu $EUID "$@" i3lock + } + + trap kill_i3lock TERM INT + + $I3LOCK {XSS_SLEEP_LOCK_FD}<&- + + exec {XSS_SLEEP_LOCK_FD}<&- + + while kill_i3lock -0; do + sleep 0.5 + done + else + trap 'kill %%' TERM INT + $I3LOCK + wait + fi + ''; +in +{ + services.screen-locker = { + enable = true; + inactiveInterval = 5; + + xss-lock.extraOptions = singleton "--transfer-sleep-lock"; + + lockCmd = toString locker; + }; +} diff --git a/home-manager/modules/xmonad/default.nix b/home-manager/modules/xmonad/default.nix index 6fc7e83..b0e9984 100644 --- a/home-manager/modules/xmonad/default.nix +++ b/home-manager/modules/xmonad/default.nix @@ -4,7 +4,6 @@ name = "xmonad.hs"; file = ./xmonad.hs; substitutes = { - "lightLockerCommand" = "${pkgs.lightlocker}/bin/light-locker-command"; "brightnessctl" = lib.getExe pkgs.brightnessctl; "playerctl" = lib.getExe pkgs.playerctl; "dmenu_run" = "${pkgs.dmenu}/bin/dmenu_run"; diff --git a/home-manager/modules/xmonad/xmonad.hs b/home-manager/modules/xmonad/xmonad.hs index a69e25e..430ac3a 100644 --- a/home-manager/modules/xmonad/xmonad.hs +++ b/home-manager/modules/xmonad/xmonad.hs @@ -138,7 +138,7 @@ myKeymap c = , ("M-S-l", withFocused (xMoveWindow ( 0,-10))) , ("M-S-ß", withFocused (xMoveWindow ( 10, 0))) - , ("M-z", spawn "@lightLockerCommand@ --lock") + , ("M-z", spawn "loginctl lock-session") , ("" , spawn "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle") , ("" , spawn "wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+")