You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.2 KiB
Bash
46 lines
1.2 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
LOCK_ICON="$HOME/.local/share/i3lock-blur/lock.png"
|
|
IMAGE=$(mktemp --suffix=.png)
|
|
TMP_IMAGE=$(mktemp --suffix=.png)
|
|
|
|
RES=$(xdpyinfo | awk '/dimensions/{print $2}')
|
|
|
|
# initial blurred screen
|
|
ffmpeg -f x11grab \
|
|
-video_size $RES \
|
|
-y -i $DISPLAY \
|
|
-filter_complex "boxblur=5:1" \
|
|
-vframes 1 $IMAGE \
|
|
-loglevel quiet
|
|
|
|
# inserting a lock in the center of each display
|
|
while read LINE
|
|
do
|
|
if [[ "$LINE" =~ ([0-9]+)x([0-9]+)\+([0-9]+)\+([0-9]+) ]]; then
|
|
# matched connected display, copying into temp image
|
|
cp $IMAGE $TMP_IMAGE
|
|
|
|
# BASH_REMATCH is ... H_RES V_RES X_offset Y_offset
|
|
# finding midpoint of display + offset - lock dims
|
|
MIDXi=$((${BASH_REMATCH[1]} / 2 + ${BASH_REMATCH[3]} - 30))
|
|
MIDYi=$((${BASH_REMATCH[2]} / 2 + ${BASH_REMATCH[4]} - 30))
|
|
|
|
# inserting lock into center of the display on the image
|
|
ffmpeg -y \
|
|
-i $TMP_IMAGE \
|
|
-i $LOCK_ICON \
|
|
-filter_complex "overlay=$MIDXi:$MIDYi" \
|
|
-vframes 1 $IMAGE \
|
|
-loglevel quiet
|
|
|
|
fi
|
|
done <<<"$(xrandr)"
|
|
|
|
|
|
gpg-connect-agent --no-autostart reloadagent /bye
|
|
i3lock -n -i "$IMAGE"
|
|
|
|
# clean up
|
|
rm $IMAGE $TMP_IMAGE
|