18 Commits

Author SHA1 Message Date
Dolores Portalatin
35a2b5d8f3 made the start of a lua script that is very fast 2018-08-09 04:24:52 -04:00
Dolores Portalatin
f85e364140 fixed variable name 2018-08-08 18:44:05 -04:00
Dolores Portalatin
2a63d39bcd updated language support 2018-08-08 18:21:26 -04:00
Dolores Portalatin
953987819a updated screenshot in the readme 2018-08-07 16:41:09 -04:00
Dolores Portalatin
7d1b255144 updated readme 2018-08-07 16:37:41 -04:00
Dolores Portalatin
a9b34bb2e4 added makefile for easy install and updated script to hardlink to icon 2018-08-07 16:24:48 -04:00
Dolores Portalatin
fe317e078d changed lock to i3lock-fancy-dualmonitor 2018-08-07 16:19:40 -04:00
Dolores Portalatin
40a02ec59a changed font rendering so its prettier and more legible on white backgrounds 2018-08-07 16:16:40 -04:00
Dolores Portalatin
44e3ba3bd8 updated dual monitors locker with new ring color syntax 2018-08-06 22:19:04 -04:00
Dolores Portalatin
0fcb93355a Merge pull request #56 from MagiCrazy/dualmonitors
Resolves #35
2016-10-14 18:36:13 -04:00
Magic.Crazy
1d7ca7e193 fix bluriness on left screens 2016-10-14 15:04:52 +02:00
meskarune
1c32f7e2b4 changed text blur so its more defined around the font 2016-04-08 11:19:40 -04:00
meskarune
428daf38e4 fixed typo in shebang 2016-04-06 12:10:30 -04:00
meskarune
7602909dce removed uneeded icon and uneeded variable 2016-04-06 12:06:40 -04:00
meskarune
eeb4f1ee97 changed text style color to look better and added text shadow 2016-04-06 12:03:24 -04:00
meskarune
f6e88602d4 changed icon/font to grey with outline 2016-04-05 22:38:17 -04:00
meskarune
05324067c9 added text support 2016-04-03 21:33:12 -04:00
meskarune
15e0d6fdee added dual monitor support 2016-04-03 20:49:44 -04:00
6 changed files with 47 additions and 136 deletions

View File

@@ -1,61 +1,13 @@
i3lock-fancy
============
This is an i3lock bash script that takes a screenshot of the desktop, blurs the background and adds a lock icon and text
website: [github pages website](http://meskarune.github.io/i3lock-fancy/)
![screen shot of lockscreen](https://raw.githubusercontent.com/meskarune/i3lock-fancy/master/screenshot.png)
Dependancies
------------
* <s>[i3lock-color-git](https://github.com/eBrnd/i3lock-color)</s>
* [i3lock-color-git](https://github.com/Arcaena/i3lock-color) - this is a fork of i3lock-color that is kept up to date with i3lock
* [i3lock-color-git](https://github.com/Arcaena/i3lock-color)
* imagemagick
* scrot
* bash
* awk
* utils-linux
* lua
* Bitter Font (or change the font in the file, I will add font detection laters)
Installation
------------
Arch Linux Package: https://aur.archlinux.org/packages/i3lock-fancy-git/
Install
-------
git clone the repository and copy lock, lock.png and lockdark.png to
"/usr/local/bin"
Move lock.png into /usr/share/i3lock-fancy-dualmonitors
Usage
-----
lock [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 <fontname>, --font <fontname> Set a custom font. Type 'convert -list font' in a terminal to get a list.
example: ```lock -gpf Comic-Sans-MS```
Extras
------
The lock screen in action:
![lockscreen animation](https://raw.githubusercontent.com/meskarune/i3lock-fancy/master/action.gif)
Use this with xautolock to automatically lock the screen after a set time.
Systemd Unit file (edit for your own use):
[Unit]
Description=Lock the screen automatically after a timeout
[Service]
Type=simple
User=meskarune
Environment=DISPLAY=:0
ExecStart=/usr/bin/xautolock -time 5 -locker /usr/local/bin/lock/lock -detectsleep
[Install]
WantedBy=graphical.target
run `lua fast-blur.lua`

40
fast-blur.lua Normal file
View File

@@ -0,0 +1,40 @@
#!/usr/bin/env lua
function os.capture(cmd)
-- run a program in a seperate process and return the output as a string
local file = assert(io.popen(cmd, 'r'))
local string = assert(file:read('*a'))
file:close()
return string
end
displays = os.capture('/usr/bin/xrandr')
current = string.match(displays, 'current%s(%d+%sx%s%d+)')
resolution = string.gsub(current, '%s+', '')
lock = ""
for result in string.gmatch(displays, 'connected.-(%d+x%d+[%+%-]%d+[%+%-]%d+)') do
local width = string.match(result, '(%d+)x%d+')
local height = string.match(result, '%d+x(%d+)')
local Xoffset = string.match(result, '[%+%-](%d+)[%+%-]%d+')
local Yoffset = string.match(result, '[%+%-]%d+[%+%-](%d+)')
local centerX = (width / 2 + Xoffset)
local centerY = (height / 2 + Yoffset)
local MIDXi = (centerX - 30)
local MIDYi = (centerY - 30)
local MIDXt = (centerX - 142.5)
local MIDYt = (centerY + 160)
local magic = "-font Bitter -pointsize 26 -fill white -annotate +%g+%g 'Type password to unlock' /usr/share/i3lock-fancy-dualmonitor/lock.png -geometry +%g+%g -composite "
lock = lock .. string.format(magic, MIDXt, MIDYt, MIDXi, MIDYi)
end
image = string.format("%s.png", os.tmpname())
makebackground = string.format("convert -size %s xc:'rgba(0, 0, 0, 0.2)' %s %s", resolution, lock, image)
i3lock = string.format("i3lock -i %s --blur 5", image)
os.execute(makebackground)
os.execute(i3lock)

81
lock
View File

@@ -1,81 +0,0 @@
#!/usr/bin/env bash
# Author: Dolores Portalatin <hello@doloresportalatin.info>
# 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"
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 <fontname>, --font <fontname> 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
# get path where the script is located to find the lock icon
SCRIPTPATH=$(realpath "$0")
SCRIPTPATH=${SCRIPTPATH%/*}
# l10n support
TEXT="Type password to unlock"
case "$LANG" in
de_* ) TEXT="Bitte Passwort eingeben" ;; # Deutsch
en_* ) TEXT="Type password to unlock" ;; # English
es_* ) TEXT="Ingrese su contraseña" ;; # Española
fr_* ) TEXT="Entrez votre mot de passe" ;; # Français
pl_* ) TEXT="Podaj hasło" ;; # Polish
esac
VALUE="60" #brightness value to compare to
scrot -z "$IMAGE"
COLOR=$(convert "$IMAGE" -gravity center -crop 100x100+0+0 +repage -colorspace hsb \
-resize 1x1 txt:- | awk -F '[%$]' 'NR==2{gsub(",",""); printf "%.0f\n", $(NF-1)}');
if [ "$COLOR" -gt "$VALUE" ]; then #white background image and black text
BW="black"
ICON="$SCRIPTPATH/lockdark.png"
PARAM=(--textcolor=00000000 --insidecolor=0000001c --ringcolor=0000003e \
--linecolor=00000000 --keyhlcolor=ffffff80 --ringvercolor=ffffff00 \
--separatorcolor=22222260 --insidevercolor=ffffff1c \
--ringwrongcolor=ffffff55 --insidewrongcolor=ffffff1c)
else #black
BW="white"
ICON="$SCRIPTPATH/lock.png"
PARAM=(--textcolor=ffffff00 --insidecolor=ffffff1c --ringcolor=ffffff3e \
--linecolor=ffffff00 --keyhlcolor=00000080 --ringvercolor=00000000 \
--separatorcolor=22222260 --insidevercolor=0000001c \
--ringwrongcolor=00000055 --insidewrongcolor=0000001c)
fi
convert "$IMAGE" "${HUE[@]}" "${EFFECT[@]}" -font "$FONT" -pointsize 26 -fill "$BW" -gravity center \
-annotate +0+160 "$TEXT" "$ICON" -gravity center -composite "$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

BIN
lock.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 300 KiB

After

Width:  |  Height:  |  Size: 283 KiB