#!/bin/sh
#
set -o nounset
set -o errexit
NAME="$USER"
FILE="/tmp/unlock-hint.png"
WIDTH=`xrandr | grep '*' | cut -dx -f1 | awk -F "\n" 'min=="" || $1 < min {min=$1} END{ print min}'`
HINT="Type the password of $NAME and <Enter> to unlock."
LENGTH=`expr length "$HINT"`
SIZE=`expr $WIDTH \* 16 / 10 / $LENGTH`
convert -size "$WIDTH"x`expr $SIZE \* 3 / 2` xc:transparent -font Courier -pointsize $SIZE -fill DimGrey \
-draw "text `expr $SIZE / 2`,$SIZE '$HINT'" "$FILE"
i3lock --dpms --color=000000 --image="$FILE" --tiling
