diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7abdc8b --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +PREFIX = $(HOME)/.local + +.PHONY: install +install: + mkdir -p $(PREFIX)/share/i3lock-blur + mkdir -p $(PREFIX)/bin + cp i3lock-blur $(PREFIX)/bin/ + cp lock.png $(PREFIX)/share/i3lock-blur/ + +.PHONY: uninstall +uninstall: + rm -f $(PREFIX)/bin/i3lock-blur + rm -rf $(PREFIX)/share/i3lock-blur diff --git a/i3lock-blur b/i3lock-blur new file mode 100755 index 0000000..2f5e5ba --- /dev/null +++ b/i3lock-blur @@ -0,0 +1,44 @@ +#!/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)" + + +i3lock -n -i "$IMAGE" + +# clean up +rm $IMAGE $TMP_IMAGE diff --git a/i3lock-fancy-dualmonitor b/i3lock-fancy-dualmonitor deleted file mode 100755 index f28e58e..0000000 --- a/i3lock-fancy-dualmonitor +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/env bash -# Author: Dolores Portalatin -# Dependencies: imagemagick, i3lock-color-git, scrot -set -o errexit -o noclobber -o nounset - -HUE=(-level 0%,100%,0.6) -EFFECT=(-filter Gaussian -resize 20% -define filter:sigma=1.5 -resize 500.5%) -# default system sans-serif font -FONT="$(convert -list font | awk "{ a[NR] = \$2 } /family: $(fc-match sans -f "%{family}\n")/ { print a[NR-1]; exit }")" -#IMAGE="$(mktemp).png" -IMAGE=$(mktemp --suffix=.png) -SHOT=(import -silent -window root) -DM=$(xdpyinfo | awk '/^ dimensions(.+([0-9]+))/{print $2}') - -OPTIONS="Options: - -h, --help This help menu. - -g, --greyscale Set background to greyscale instead of color. - -p, --pixelate Pixelate the background instead of blur, runs faster. - -f , --font Set a custom font. Type 'convert -list font' in a terminal to get a list." - -# move pipefail down as for some reason "convert -list font" returns 1 -set -o pipefail -trap 'rm -f "$IMAGE"' EXIT -TEMP="$(getopt -o :hpgf: -l help,pixelate,greyscale,font: --name "$0" -- "$@")" -eval set -- "$TEMP" - -while true ; do - case "$1" in - -h|--help) - printf "Usage: $(basename $0) [options]\n\n$OPTIONS\n\n" ; exit 1 ;; - -g|--greyscale) HUE=(-level 0%,100%,0.6 -set colorspace Gray -separate -average) ; shift ;; - -p|--pixelate) EFFECT=(-scale 10% -scale 1000%) ; shift ;; - -f|--font) - case "$2" in - "") shift 2 ;; - *) FONT=$2 ; shift 2 ;; - esac ;; - --) shift ; break ;; - *) echo "error" ; exit 1 ;; - esac -done - -# l10n support -TEXT="Type password to unlock" -case "${LANG:-}" in - de_* ) TEXT="Bitte Passwort eingeben" ;; # Deutsch - da_* ) TEXT="Indtast adgangskode" ;; # Danish - en_* ) TEXT="Type password to unlock" ;; # English - es_* ) TEXT="Ingrese su contraseña" ;; # Española - fr_* ) TEXT="Entrez votre mot de passe" ;; # Français - he_* ) TEXT="הליענה לטבל המסיס דלקה" ;; # Hebrew עברית (convert doesn't play bidi well) - id_* ) TEXT="Masukkan kata sandi Anda" ;; # Bahasa Indonesia - it_* ) TEXT="Inserisci la password" ;; # Italian - ja_* ) TEXT="パスワードを入力してください" ;; # Japanese - lv_* ) TEXT="Ievadi paroli" ;; # Latvian - pl_* ) TEXT="Podaj hasło" ;; # Polish - pt_* ) TEXT="Digite a senha para desbloquear" ;; # Português - ru_* ) TEXT="Введите пароль" ;; # Russian - * ) TEXT="Type password to unlock" ;; # Default to English -esac - -#scrot -z "$IMAGE" -command -- "${SHOT[@]}" "$IMAGE" - -ICON="/usr/share/i3lock-fancy-dualmonitor/lock.png" -PARAM=("--insidecolor=0000001c" "--ringcolor=0000003e" \ - "--linecolor=00000000" "--keyhlcolor=ffffff80" "--ringvercolor=ffffff00" \ - "--separatorcolor=22222260" "--insidevercolor=ffffff1c" \ - "--ringwrongcolor=ffffff55" "--insidewrongcolor=ffffff1c" \ - "--verifcolor=ffffff00" "--wrongcolor=ff000000" "--timecolor=ffffff00" \ - "--datecolor=ffffff00" "--layoutcolor=ffffff00") - -LOCK=() -while read LINE -do - if [[ "$LINE" =~ ([0-9]+)x([0-9]+)\+([0-9]+)\+([0-9]+) ]]; then - W=${BASH_REMATCH[1]} - H=${BASH_REMATCH[2]} - Xoff=${BASH_REMATCH[3]} - Yoff=${BASH_REMATCH[4]} - MIDXi=$(($W / 2 + $Xoff - 60 / 2)) - MIDYi=$(($H / 2 + $Yoff - 60 / 2)) - MIDXt=$(($W / 2 + $Xoff - 285 / 2)) - MIDYt=$(($H / 2 + $Yoff + 320 / 2)) - MIDXts=$(($MIDXt + 2)) - MIDYts=$(($MIDYt + 2)) - LOCK+=(\( -size $DM xc:none -font $FONT -pointsize 26 -fill black -annotate +$MIDXts+$MIDYts "$TEXT" -blur 0x2 \ - -fill black -annotate +$MIDXts+$MIDYts "$TEXT" -blur 0x1 -fill white -annotate +$MIDXt+$MIDYt "$TEXT" \) \ - -flatten \ - $ICON -geometry +$MIDXi+$MIDYi -composite) - fi -done <<<"$(xrandr)" - -convert "$IMAGE" "${HUE[@]}" "${EFFECT[@]}" "${LOCK[@]}" "$IMAGE" - -# try to use a forked version of i3lock with prepared parameters -if ! i3lock -n "${PARAM[@]}" -i "$IMAGE" > /dev/null 2>&1; then - # We have failed, lets get back to stock one - i3lock -n -i "$IMAGE" -fi diff --git a/lock.sh b/lock.sh deleted file mode 100755 index 635a443..0000000 --- a/lock.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -TMPBG=/tmp/screen.png -LOCK=$HOME/lock.png -RES=$(xrandr | grep 'current' | sed -E 's/.*current\s([0-9]+)\sx\s([0-9]+).*/\1x\2/') - -ffmpeg -f x11grab -video_size $RES -y -i $DISPLAY -i $LOCK -filter_complex "boxblur=5:1,overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2" -vframes 1 $TMPBG -loglevel quiet -i3lock -i $TMPBG -rm $TMPBG diff --git a/res b/res deleted file mode 100755 index a318395..0000000 --- a/res +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -SR="$(xrandr -q | grep ' connected ' | grep -o '[0-9]*x[0-9]*+[0-9]*+[0-9]*')" - -for RES in $SR; do - W="$(awk -F '[x+]' '{print $1}' <<< "$RES")" - H="$(awk -F '[x+]' '{print $2}' <<< "$RES")" - Xoff="$(awk -F '[x+]' '{print $3}' <<< "$RES")" - Yoff="$(awk -F '[x+]' '{print $4}' <<< "$RES")" - MIDX=$(($W / 2 + $Xoff - 60 / 2)) - MIDY=$(($H / 2 + $Yoff - 60 / 2)) - printf "X: $W\nY: $H\nX-offset: $Xoff\nY-offset: $Yoff\nmiddlex: $MIDX\nmiddley: $MIDY\n" -done - -while read LINE -do - if [[ "$LINE" =~ ([0-9]+)x([0-9]+)\+([0-9]+)\+([0-9]+) ]]; then - W=${BASH_REMATCH[1]} - H=${BASH_REMATCH[2]} - Xoff=${BASH_REMATCH[3]} - Yoff=${BASH_REMATCH[4]} - MIDX=$(($W / 2 + $Xoff - 60 / 2)) - MIDY=$(($H / 2 + $Yoff - 60 / 2)) - printf "X: $W\nY: $H\nX-offset: $Xoff\nY-offset: $Yoff\nmiddlex: $MIDX\nmiddley: $MIDY\n" - fi -done <<<"$(xrandr)"