diff --git a/Digital_tech.otf b/Digital_tech.otf new file mode 100644 index 0000000..601ab35 Binary files /dev/null and b/Digital_tech.otf differ diff --git a/README.md b/README.md index 6655684..1e477cc 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,17 @@ i3lock-fancy ============ -i3lock script that takes a screenshot of the desktop, blurs the background and adds a lock icon and text +i3lock script that takes desktop screenshot, blurs and darken the background and adds a lock icon and text. I modified the original script (by [meskarune](https://github.com/meskarune)): this version can accept a custom text as an input, if no text is provided it applies the default "type password to unlock". + +Update: New version uses ffmpeg instead of scrot and imagemagick. Thanks to [/u/edijatszik](https://www.reddit.com/r/unixporn/comments/4yj29e/i3lock_simple_blur_script/) ([Github link](https://github.com/petvas/i3lock-blur)). The way I darken the background is a bit cheaty but it works. There is probably a better way. Depends: -* [i3lock-color-git](https://github.com/eBrnd/i3lock-color) -* imagemagick -* scrot -* Liberation Fonts +* [i3lock-color-git](https://github.com/Arcaena/i3lock-color) +* ffmpeg +* Digital Tech font (included) Screenshot: -![lockscreen](https://raw.githubusercontent.com/meskarune/i3lock-fancy/master/screenshot.png) +![lockscreen](https://raw.githubusercontent.com/Ema0/i3lock-fancy/master/screenshot.png) + + diff --git a/lock b/lock index 223aab1..b79bd71 100755 --- a/lock +++ b/lock @@ -1,20 +1,24 @@ #!/bin/bash - + # Dependencies: -# imagemagick +# ffmpeg # i3lock-color-git -# scrot - + IMAGE=/tmp/i3lock.png - -# All options are here: http://www.imagemagick.org/Usage/blur/#blur_args -#BLURTYPE="0x5" # 7.52s -#BLURTYPE="0x2" # 4.39s -#BLURTYPE="5x3" # 3.80s -BLURTYPE="2x8" # 2.90s -#BLURTYPE="2x3" # 2.92s +TEXT="locked" +SCRIPT=`realpath $0` +SCRIPTPATH=`dirname $SCRIPT` +LOCK=$SCRIPTPATH/lock.png +RES=$(xrandr --current | grep '*' | uniq | awk '{print $1}') +#This is a bit cheaty +BOXSIZE=$(expr $(echo $RES | cut -d 'x' -f1) / 2) + +if [[ $1 != "" ]]; then + TEXT=$1 +fi + +ffmpeg -f x11grab -video_size $RES -y -i $DISPLAY -i $LOCK -filter_complex "boxblur=5,drawtext=fontfile=$SCRIPTPATH/Digital_tech.otf:text=$TEXT:fontcolor='#ffffffe0':fontsize=40:x=(w-tw)/2:y=(h/PHI)+th:shadowcolor='#1d1f21d0':shadowx=2:shadowy=2:box=1:boxcolor=#1a1b22@0.4:boxborderw=$BOXSIZE,overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2" -vframes 1 $IMAGE -scrot $IMAGE -convert $IMAGE -level 0%,100%,0.6 -blur $BLURTYPE -font Liberation-Sans -pointsize 26 -fill white -gravity center -annotate +0+200 'Type password to unlock' - | composite -gravity center lock.png - $IMAGE i3lock --textcolor=ffffff00 --insidecolor=ffffff1c --ringcolor=ffffff3e --linecolor=ffffff00 --keyhlcolor=00000080 --ringvercolor=00000000 --insidevercolor=0000001c --ringwrongcolor=00000055 --insidewrongcolor=0000001c -i $IMAGE + rm $IMAGE diff --git a/screenshot.png b/screenshot.png index 084b600..d5b6dc6 100644 Binary files a/screenshot.png and b/screenshot.png differ