Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35a2b5d8f3 | ||
|
|
f85e364140 | ||
|
|
2a63d39bcd | ||
|
|
953987819a | ||
|
|
7d1b255144 | ||
|
|
a9b34bb2e4 | ||
|
|
fe317e078d | ||
|
|
40a02ec59a | ||
|
|
44e3ba3bd8 | ||
|
|
0fcb93355a | ||
|
|
1d7ca7e193 | ||
|
|
1c32f7e2b4 | ||
|
|
428daf38e4 | ||
|
|
7602909dce | ||
|
|
eeb4f1ee97 | ||
|
|
f6e88602d4 | ||
|
|
05324067c9 | ||
|
|
15e0d6fdee |
62
README.md
62
README.md
@@ -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/)
|
||||
|
||||

|
||||
|
||||
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:
|
||||
|
||||

|
||||
|
||||
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
40
fast-blur.lua
Normal 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
81
lock
@@ -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
BIN
lock.png
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 2.5 KiB |
BIN
lockdark.png
BIN
lockdark.png
Binary file not shown.
|
Before Width: | Height: | Size: 1.8 KiB |
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
|
Before Width: | Height: | Size: 300 KiB After Width: | Height: | Size: 283 KiB |
Reference in New Issue
Block a user