mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-26 18:16:13 +01:00
aff0158ef7
Signed-off-by: magic_rb <magic_rb@redalder.org>
60 lines
1.3 KiB
Nix
60 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;
|
|
};
|
|
}
|