#!/bin/sh

wallpaper="$HOME/.config/i3/wallpapers/maxresdefault.jpg"
cached="$HOME/.cache/i3lock/wallpaper.png"
dims_cache="$HOME/.cache/i3lock/dims.txt"
dims=$(xdotool getdisplaygeometry | tr ' ' 'x')

if [ ! -f "$cached" ] || \
   [ "$(stat -c %Y "$wallpaper")" -gt "$(stat -c %Y "$cached")" ] || \
   [ "$dims" != "$(cat "$dims_cache" 2>/dev/null)" ]; then
  mkdir -p "$HOME/.cache/i3lock"
  convert "$wallpaper" -resize "$dims^" -extent "$dims" PNG:- > "$cached"
  echo -n "$dims" > "$dims_cache"
fi

i3lock \
--image "$cached" \
--clock \
--indicator \
--radius 100 \
--ring-width 8 \
--color=000000ff \
--ring-color=2f4058ff \
--inside-color=1f1f28ff \
--line-color=00000000 \
--separator-color=3a3a46ff \
--keyhl-color=6daeeaff \
--bshl-color=c7162bff \
--ringver-color=4a90d9ff \
--insidever-color=1f1f28ff \
--ringwrong-color=c7162bff \
--insidewrong-color=1f1f28ff \
--time-color=d0d0d0ff \
--date-color=9a9a9aff \
--layout-color=d0d0d0ff \
--verif-color=d0d0d0ff \
--wrong-color=d0d0d0ff
