meskarune / i3lock-fancy Goto Github PK
View Code? Open in Web Editor NEWi3lock script that takes a screenshot of the desktop, blurs the background and adds a lock icon and text
License: MIT License
i3lock script that takes a screenshot of the desktop, blurs the background and adds a lock icon and text
License: MIT License
I have a command that will lock the screen and then suspend the system so the lock screen is shown when the system resumes. However, when using it with i3lock-fancy instead, it will lock the screen and the suspend will not occur. It will then suspend after I unlock the screen.
set $Locker i3lock-fancy
set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown
mode "$mode_system" {
bindsym l exec --no-startup-id $Locker, mode "default"
bindsym e exec --no-startup-id i3-msg exit, mode "default"
bindsym s exec --no-startup-id $Locker && systemctl suspend, mode "default"
bindsym h exec --no-startup-id $Locker && systemctl hibernate, mode "default"
bindsym r exec --no-startup-id systemctl reboot, mode "default"
bindsym Shift+s exec --no-startup-id systemctl poweroff -i, mode "default"
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+Pause mode "$mode_system"
This code works just fine with regular i3lock but not with i3lock-fancy. Is there something I need to do differently with it or is there some limitation or bug that I'm running into?
Is it a bug or non-goal in i3lock or i3lock-color that you can still switch to for example tty 2 with a key combination?
I've used screen lockers that really lock the screen and prevent such behavior, so I'm irritated that this is possible with i3lock based screen lockers.
I like to use grayscale via this imagemagick option: -set colorspace Gray -separate -average
I've been playing with adding in a native, c-based gaussian blur effect to i3lock-color when I do the next feature enhancement (I'll likely be adding some clock options and font options """soon""" as well). I recently found this when dicking around on github during lectures, which has given me some ideas on how to implement gaussian blurring.
This will offer a few advantages over blurring a screenshot:
Eventually I may add an option to grab the current screenbuffer (and require blurring), or have the blur option take the screenshot (the logic being that if you want a blurred image, you should preblur it and save that - so using the blur
option will implicitly mean you want a screenshot.)
One of the downsides of this is that jesus christ, I'm running out of single character options and the options for invoking this are getting complicated. I might also have to look into setting a config file (maybe under XDG_CONFIG_HOME/i3/lock.cfg
?) to simplify things.
Thoughts?
(Also, I never realized there was an aur package for my fork; I completely forgot to ever make one, but it's nice to have someone else maintaining packaging it)
Works fine otherwise, but when I add i3lock-fancy to the startup files in i3config, I get only a black background.
Here's how I start it:
exec --no-startup-id i3lock-fancy
One thing to note that if I change the command to exec_always and restart i3 it works fine. Seems that the utility to create the screenshot might not be ready when it's only started on first startup.
Using the latest version of both i3lock-fancy-git and i3lock-color-git from AUR, the scripts hangs on the line:
temp="$(getopt -o :hdnpglt:f: -l desktop,help,listfonts,nofork,pixelate,greyscale,text:,font: --name "$0" -- "$@")"
The command I'm using to run is i3lock-fancy -p --scrot. Removing --scrot just makes the crash take some more time.
Latest everything, not on testing. What other info should I provide?
On my laptop i use bumblebee for my optimus nvidia and when i lock laptop, i3lock-fancy modprobe nvidia driver and after my videocard state is on, here is log
~ $ lock
modprobe: ERROR: could not insert 'nvidia': No such device
modprobe: ERROR: could not insert 'nvidia': No such device
and after
Bumblebee status: Ready (3.2.1). X inactive. Discrete video card is on.
Distro is Archlinux, and sorry for my bad english
Hi so i3lock -k will show the current time and i would like to know how i can modify the code for i3lock-fancy to show the time.
when lauched from terminal I get folowing:
convert.im6: unable to read font
Liberation-Sans' @ warning/annotate.c/RenderType/853.`
When I run fc-list | grep "Liberation-Sans"
it doesn't find anything but with fc-list | grep "Liberation Sans"
i get folowing results:
/usr/share/fonts/truetype/liberation/LiberationSansNarrow-Italic.ttf: Liberation Sans Narrow:style=Italic
/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf: Liberation Sans:style=Regular
/usr/share/fonts/truetype/liberation/LiberationSansNarrow-Regular.ttf: Liberation Sans Narrow:style=Regular
/usr/share/fonts/truetype/liberation/LiberationSans-Italic.ttf: Liberation Sans:style=Italic
/usr/share/fonts/truetype/liberation/LiberationSansNarrow-BoldItalic.ttf: Liberation Sans Narrow:style=Bold Italic
/usr/share/fonts/truetype/liberation/LiberationSans-BoldItalic.ttf: Liberation Sans:style=Bold Italic
/usr/share/fonts/truetype/liberation/LiberationSansNarrow-Bold.ttf: Liberation Sans Narrow:style=Bold
/usr/share/fonts/truetype/liberation/LiberationSans-Bold.ttf: Liberation Sans:style=Bold
So the problem seems that ubuntu doesn't have Liberation-Sans font and uses Liberation Sans
Hello!
I congratulate you on this excellent work!
I have any questions with autolock ?
First question:
the following scripts , which have save path, and name given to the scripts ?
[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
Second question:
I use Archlinux . as I do for the autolock script starts?
I hope you can answer me!
And I again thank you for such a great work...
if you could make 'import' and other executables variables defined at the beginning of the script, this would spare myself keeping up to date with changes in the script and just patch thevariables. Right now I'm patching every occurence of binaries to store-paths so that the references in Guix aren't garbage collected.
As from the README of this fork, it seems that the lock icon and the circle in the middle isn't Black/Grey/White. Whenever I type my password, The circle would be green with a "blue" verified when it's done, any idea how to fix this? Thanks!
Hello!
I use two layouts one is English, second is Cyrillic and I am not able to exit from lock-screen if the layout was Cyrillic. How do I change my keyboard layout to English before locking? I mean what lines do I need to add to the script to do it automatically. I tried just to add "setxkbmap -layout us" at the end of script but it doesn't seem to work. Any help would be appreciated!
Hi,
To lock my screen, I usually run Rofi and type lock
. This unfortunately leads to the Rofi dialog being shown in the background image (like shown below).
Before discovering i3lock-fancy, I used a custom script that had sleep $FEW_MILLIS
in the top of it to avoid that.
I suggest adding a feature in i3lock-fancy to allow the user to specify a delay before taking the screenshot, in order to wait for the run dialog to close.
If you're okay with this, I can make a pull request.
Thank you.
It worked briefly though, not sure what the problem is...
This is what I get:
composite: unable to open image `lock.png': No such file or directory @ error/blob.c/OpenBlob/2701.
composite: unable to open file `lock.png' @ error/png.c/ReadPNGImage/3913.
composite: missing an image filename `/tmp/i3lock.png' @ error/composite.c/CompositeImageCommand/1616.
[redacted@redacted-arch i3lock-fancy-git]$ makepkg -si
==> Making package: i3lock-fancy-git r125.e7eb9e7-1 (Wed May 24 15:35:33 IST 2017)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
-> Updating i3lock-fancy git repo...
Fetching origin
-> Found package.patch
==> Validating source files with md5sums...
i3lock-fancy ... Skipped
package.patch ... Passed
==> Extracting sources...
-> Creating working copy of i3lock-fancy git repo...
Switched to a new branch 'makepkg'
==> Starting pkgver()...
==> Removing existing $pkgdir/ directory...
==> Starting build()...
patching file /home/redacted/i3lock-fancy-git/src/i3lock-fancy/lock
Hunk #1 FAILED at 79.
1 out of 1 hunk FAILED -- saving rejects to file /home/redacted/i3lock-fancy-git/src/i3lock-fancy/lock.rej
==> ERROR: A failure occurred in build().
Aborting...
Arch, fully up to date system. What gives?
I've had this installed and used it for a bit but hadn't tried it until I saw a recent AUR update. Now whenever I try it the script just exits without locking. It looks like it's performing the operations correctly.
[parker@x3720 Pictures]$ bash -x `which i3lock-fancy`
+ HUE='-level 0%,100%,0.6'
+ EFFECT='-filter Gaussian -resize 20% -define filter:sigma=1.5 -resize 500.5%'
++ convert -list font
+++ fc-match sans -f '%{family}\n'
++ awk '{ a[NR] = $2 } /family: DejaVu Sans/ { print a[NR-1]; exit }'
+ FONT=DejaVu-Sans
++ mktemp
+ IMAGE=/tmp/tmp.X9C1OV7jcZ.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.'
+ set -o errexit -o noclobber -o nounset -o pipefail
++ getopt -o :hpgf: -l help,pixelate,greyscale,font: --name /usr/bin/i3lock-fancy --
+ TEMP=' --'
+ eval set -- ' --'
++ set -- --
+ true
+ case "$1" in
+ shift
+ break
+ SCRIPTPATH=/usr/share/i3lock-fancy
+ TEXT='Type password to unlock'
+ case $LANG in
+ TEXT='Type password to unlock'
+ VALUE=60
+ scrot -z /tmp/tmp.X9C1OV7jcZ.png
++ convert /tmp/tmp.X9C1OV7jcZ.png -gravity center -crop 100x100+0+0 +repage -colorspace hsb -resize 1x1 txt:-
++ sed -E '/.*$/ {
N
s/.*\n.*([0-9]{1,2}[^\.])\.[0-9]+%\)$/\1/
}'
+ COLOR=21
+ '[' 21 -gt 60 ']'
+ BW=white
+ ICON=/usr/share/i3lock-fancy/lock.png
+ PARAM='--textcolor=ffffff00 --insidecolor=ffffff1c --ringcolor=ffffff3e \
--linecolor=ffffff00 --keyhlcolor=00000080 --ringvercolor=00000000 \
--separatorcolor=22222260 --insidevercolor=0000001c \
--ringwrongcolor=00000055 --insidewrongcolor=0000001c'
+ convert /tmp/tmp.X9C1OV7jcZ.png -level 0%,100%,0.6 -filter Gaussian -resize 20% -define filter:sigma=1.5 -resize 500.5% -font DejaVu-Sans -pointsize 26 -fill white -gravity center -annotate +0+160 'Type password to unlock' /usr/share/i3lock-fancy/lock.png -gravity center -composite /tmp/tmp.X9C1OV7jcZ.png
+ i3lock --textcolor=ffffff00 --insidecolor=ffffff1c --ringcolor=ffffff3e '\' --linecolor=ffffff00 --keyhlcolor=00000080 --ringvercolor=00000000 '\' --separatorcolor=22222260 --insidevercolor=0000001c '\' --ringwrongcolor=00000055 --insidewrongcolor=0000001c -i /tmp/tmp.X9C1OV7jcZ.png
EDIT2: Oh so I realized it was trying to run i3lock and not i3lock-color. Tried with i3lock-color and I just get an error.
[parker@x3720 Pictures]$ i3lock --textcolor=ffffff00 --insidecolor=ffffff1c --ringcolor=ffffff3e '\' --linecolor=ffffff00 --keyhlcolor=0000sidewrongcolor=0000001c -i /tmp/tmp.X9C1OV7jcZ.png
bash: i3lock: command not found
[parker@x3720 Pictures]$ i3lock-color --textcolor=ffffff00 --insidecolor=ffffff1c --ringcolor=ffffff3e '\' --linecolor=ffffff00 --keyhlcolor=0000sidewrongcolor=0000001c -i /tmp/tmp.X9C1OV7jcZ.png
i3lock-color: keyhlcolor is invalid, color must be given in 8-byte format: rrggbb
EDIT3: i3lock-color-git AUR package seems to have some issues. https://aur.archlinux.org/packages/i3lock-color-git/#news Not sure if that's what's causing this problem.
EDIT4: It seems to JUST be the script name it's calling. When I tried running the command by itself my copy and paste ate some characters. It does work as intended with the i3lock reference replaced with i3lock-color. Should clear itself up once i3lock-color-git updates the references. Closing out...
I want to start this on suspend, but not after a specific time, I therefore do not use xautolock.
Therefore I made a forking systemd service that runs before sleep.target and starts i3lock-fancy.
This however required me to edit the script and remove the -n parameter.
Could this become a command line option?
Hi, I was wondering if it was just me or is the script really slow ?
I guess need some config to .i3/config
I am curious how i3lock-fancy interacts with slick-greeter, the greeter which comes with Solus, the operating system of my choice. Could you explain this process in non-technical terms? And secondly, what would I do if i3lock-fancy locks a user out by causing problems with the default screen lock mechanisms at place in various operating systems?
Hello, I've been using this lock setup with a manual keybind on openbox for a while but was wondering if the normal -d still works with this fork?
Ex:
xautolock -time 50 -locker "i3lock-fancy -d " -lockaftersleep &
So i3lock would blank & lock the screen after 50 minutes if that ^ formatting is right..
This is unreliable, see:
http://mywiki.wooledge.org/BashFAQ/028
Also, why change directory? If it works as expected, the path is already stored in BASH_SOURCE. So you could replace
pushd $(dirname $0) > /dev/null
SCRIPTPATH=$(pwd)
popd > /dev/null
with
SCRIPTPATH=${BASH_SOURCE%/*}
As found out in #80 a Makefile would make sense.
I can try my hands on a Makefile, I'm patching many things by hand now to include references to store items in Guix.
In the AUR-package the dependency on i3lock-color
is not specified directly. Instead the package depends on i3lock
which is misleading, especially if you have i3lock
already installed
BUG: running the script as "lock --desktop" fails silently.
REASON: On line 39, the call to "getopt" is missing an entry for the long option "desktop"
BUGFIX: Change the line to read:
TEMP="$(getopt -o :hdpglt:s:f: -l help,desktop,pixelate,greyscale,text:,screenshot:,font: --name "$0" -- "$@")"
PS: This script was a great idea. Thanks for coming up with it.
hello, when using the dualmonitors branch i3lock-fancy-dualmonitors-git r81.1c32f7e-1, I get the following errors.
convert: unable to load font `-pointsize': Resource temporarily unavailable @ error/xwindow.c/XBestFont/828.
convert: unable to load font `-pointsize': Resource temporarily unavailable @ error/xwindow.c/XBestFont/828.
convert: unable to load font `-pointsize': Resource temporarily unavailable @ error/xwindow.c/XBestFont/828.
convert: unable to load font `-pointsize': Resource temporarily unavailable @ error/xwindow.c/XBestFont/828.
convert: unable to load font `-pointsize': Resource temporarily unavailable @ error/xwindow.c/XBestFont/828.
convert: unable to load font `-pointsize': Resource temporarily unavailable @ error/xwindow.c/XBestFont/828.
convert: unable to load font `-pointsize': Resource temporarily unavailable @ error/xwindow.c/XBestFont/828.
convert: unable to load font `-pointsize': Resource temporarily unavailable @ error/xwindow.c/XBestFont/828.
convert: unable to open image `26': No such file or directory @ error/blob.c/OpenBlob/2702.
convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/501.
convert: unable to open image `26': No such file or directory @ error/blob.c/OpenBlob/2702.
convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/501.
ImageMagick version:
Version: ImageMagick 6.9.3-10 Q16 x86_64 2016-05-05 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenCL OpenMP
Delegates (built-in): bzlib cairo fontconfig freetype gslib jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png ps rsvg tiff webp wmf x xml zlib
Thank you,
Senan.
Add an option to list the fonts available to use with the script.
Would it be possible to add an option to hide the text completely and just show the lock icon on the dualmonitors branch? As a temporary workaround for the text not being completely centered.
I've been having a problem with using scrot to take the screenshot for the lock screen background. It seems as if the screenshot is taken after the screen is turned off? And thereby making the lock screen background entirely black when i wake up the computer. Though this problem does not happen if i manually suspend the laptop by shutting the lid of it. I've put the following command under my i3 config:
exec_always xautolock -detectsleep -time 5 -locker '/usr/local/bin/lock -gpt "some text"'
# get path where the script is located to find the lock icon
scriptpath=$(readlink -f -- "$0")
scriptpath=${scriptpath%/*}
…
icon="$scriptpath/icons/lockdark.png"
This assumption fails when the script is located in an immutable location (/gnu/store/ in our case).
Executed directly from its root, you get this failure:
user@abyayala /gnu/store/qvlin3pmsysxqi4nkag6ibjv09l1dwk1-i3lock-fancy-0.2/bin$ ./i3lock-fancy
convert: unable to open image `/gnu/store/qvlin3pmsysxqi4nkag6ibjv09l1dwk1-i3lock-fancy-0.2/bin/icons/lockdark.png': No such file or directory @ error/blob.c/OpenBlob/2701.
convert: unable to open file `/gnu/store/qvlin3pmsysxqi4nkag6ibjv09l1dwk1-i3lock-fancy-0.2/bin/icons/lockdark.png' @ error/png.c/ReadPNGImage/4046.
convert: no images defined `/tmp/tmp.j96mGODH5q.png' @ error/convert.c/ConvertImageCommand/3258.
This error assumes that you have installed i3lock-fancy in this structure:
user@abyayala /gnu/store/qvlin3pmsysxqi4nkag6ibjv09l1dwk1-i3lock-fancy-0.2/bin$ tree ..
..
├── bin
│ └── i3lock-fancy
└── share
└── i3lock-fancy
└── icons
├── circlelockcleardark.png
├── circlelockclear.png
├── circlelockdark.png
├── circlelock.png
├── lockdark.png
├── lock.png
├── tokendark.png
└── token.png
I am going to patch this by hand again, but it makes sense to not assume relative paths. Instead just have
variable iconpath=/usr/share/i3lock-fancy or something.
I have to substitute the /usr/ anyway.
What do you think?
hey there,
the lock essentialy works, but the ring still is displayed in green, and isnt grey as its supposed to be. what could cause this and how can i change it to be as grey as in the demo?
all i did was installing the lock like explained in the readme, didnt change any properties
btw, great lock, it really looks amazing!
i3lock-fancy uses the '-n' parameter (no forking) when exec'ing i3lock. This means that i3lock doesn't fork, which makes it difficult to use in systemd unit files to lock the screen before suspending (i.e. you can't use 'Type=forking' in your unit file). 'Type=oneshot' must be used, which means that the screen will lock after the system resumes from suspend. This is a bit of a security concern, especially since i3lock takes a good 2-4 seconds to actually lock the screen due to the image processing that occurs beforehand (this is on a Skylake i7 with a 4k display.. I'd imagine 1080p screens are approximately 400% faster? So 0.5-2 seconds?).
I've just seen you disown the package i3lock-fancy in the AUR and created another package named "i3lock-fancy-dualmonitors-git". What is the reason behind this change ?
Running i3lock-fancy && sudo pm-suspend from terminal locks the screen but prevents the other command from executing. After typing in the password and unlocking the screen, computer finally suspends. I'm pretty sure this is a problem with i3lock-fancy as i3lock && sudo pm-suspend works just fine.
Can you make this package available in the AUR ?
I'm currently renaming the 'lock' script to 'i3lock-fancy' in /bin/ in the install phase of the package.
In my opinion this makes more sense than lock. Lock is very generic. It resembles the function "Now I want to lock the screen!" but it's not a unique namespace.
i3lock-fancy would fit into the i3lock-* space.
What do you think? Any other ideas?
On line 53, the case statement on $LANG could return values other than the locale, such as "C", and causes issues.
I am trying to replace the script I was using for some time:
#!/bin/bash
i3lock -i <(import -window root - | convert -blur -2x5 - png:-)
The code above stopped blurring the background, the background becomes completely white so I decided to give this repo a try. Unfortunately it does not work for me as well. When I try lock
or i3lock-fancy
it just silently exits. Is there a way to debug what's going on?
In the file called lock:
image=$(mktemp).png
Will create an empty tmp file with an auto-generated name, and then assign the variable image
to that name + .png.
Later, you trap for exits and remove the file with the .png suffix for cleanup, but the empty auto-generated file is always leaked.
Hi,
First many thanks for this great tool I like it very much :)
I would like i3lock-fancy to start automatically before I suspend my computer, then when I wake up I have the great i3lock-fancy to ask me for a password.
I created this systemd unit :
[Unit]
Description=Starts i3lock at suspend time
Before=sleep.target
[Service]
User=username
Type=forking
Environment=DISPLAY=:0
ExecStartPre=
ExecStart=/usr/bin/i3lock-fancy
[Install]
WantedBy=sleep.target
And it is working well but my computer never get to sleep. I need to type the password and then it goes to sleep!
Is there a way / parameter to pass to i3lock-fancy to handle this ?
Many thanks
First of all: This extension looks really cool!
Do you know what it takes to make it run on Ubuntu? I have not yet made it to Arch, but I am currently trying to make a minimal Ubuntu install (that is, it is based on Ubuntu mini) with i3 as wm.
Hi,
I was just wondering if the master branch could have an option to only overlay the icon on one monitor? That way, when I use my laptop with my external monitor as well as on the go the result is the same. Right now on the master branch version the icon goes in the middle.
Not sure if this is possible or not.
Thanks!
When the command below is submitted, the script blurs the screen but then the unblurred version of the screen appears every few seconds. This only happens when two monitors are in use but not when only one is connected. I noticed similar behaviour with i3lock-blur. Does the i3lock-fancy not support multiple monitors or is this a bug?
i3lock -u -f
Hello,
Could you please tag this repository?
I am the Debian Maintainer for this project and tags would help Debian keep up with new releases/bugfixes.
See:
It seems that your script is not working for dual monitors. The lock is displayed in the gap between the monitors while the type feedback indicator is displayed twice in the center of each screen. Would be great to have support for dual monitors!
hey,
i am using arch-64 with i3
if i executed bash lock
it was trowing:
locknow: line 28: [: # ImageMagick pixel enumeration: 1,1,255,hsb
0,0: (2088.43,2061.49,6284.85) #080818 hsb(11.4723,3.14563%,9.59007%): integer expression expected
i did an echo $COLOR
before the if statement
it gave: # ImageMagick pixel enumeration: 1,1,255,hsb 0,0: (2103.52,1990.89,6420.93) #080819 hsb(11.5551,3.0379%,9.79771%)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.