Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background color detection #53

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Digital_tech.otf
Binary file not shown.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)


30 changes: 17 additions & 13 deletions lock
Original file line number Diff line number Diff line change
@@ -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=#[email protected]: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
Binary file modified screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.