mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-29 19:46:17 +01:00
558a6e4168
Signed-off-by: Magic_RB <magic_rb@redalder.org>
55 lines
1.3 KiB
Nix
55 lines
1.3 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
let
|
|
inherit (lib)
|
|
singleton
|
|
getExe
|
|
makeBinPath;
|
|
|
|
locker = pkgs.writeShellScript "i3lock-dynamic-image" ''
|
|
export PATH=${makeBinPath (with pkgs; [ xorg.xrandr gnugrep coreutils imagemagick i3lock ])}:$PATH
|
|
|
|
WALLPAPER_CACHE="$HOME/.local/tmp/wallpaper_cache"
|
|
|
|
mkdir -p $WALLPAPER_CACHE
|
|
|
|
SCREEN_RESOLUTION="$(xrandr --current | grep '*' | uniq | tr -s ' ' | cut -f2 -d' ' | sort -nr | head -n 1)"
|
|
IMAGEFILE="$WALLPAPER_CACHE/$(sha256sum $HOME/.config/wallpaper | tr -s ' ' | cut -f 1 -d' ').png"
|
|
I3LOCK="i3lock -t -d -c 000000 -i $IMAGEFILE"
|
|
|
|
if ! [[ -e "$IMAGEFILE" ]]
|
|
then
|
|
convert "$HOME/.config/wallpaper" -gravity Center -background "#000000" -resize "$SCREEN_RESOLUTION^" -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;
|
|
};
|
|
}
|