Fastest lock screen using i3lock
Fastest lock screen using i3lock
This is probably the fastest bash script you have ever seen that:-
- Takes a screenshot of your desktop
- Blurs it
- Locks your screen
All of this in under a second!
The script
#!/bin/bashPICTURE=/tmp/i3lock.jpgSCREENSHOT="scrot --silent $PICTURE"$SCREENSHOTconvert -scale 10% -blur 0x0.5 -resize 1000% $PICTURE $PICTUREpkill i3locki3lock -i $PICTURErm $PICTUREHow the script works
The following was generated by chatGPT
This is a Bash shell script that takes a screenshot of the current desktop, applies a blur effect to it, sets it as the lock screen wallpaper, and then removes the temporary screenshot file. Here’s a breakdown of what each line does:
#!/bin/bashThis is known as the shebang line, which tells the system that this script should be run using the Bash shell.
PICTURE=/tmp/i3lock.jpgThis sets the variable PICTURE to the file path /tmp/i3lock.jpg.
SCREENSHOT="scrot --silent $PICTURE"This sets the variable SCREENSHOT to the command scrot —silent /tmp/i3lock.jpg, which takes a screenshot of the desktop and saves it to the file specified by PICTURE. The —silent option makes scrot run silently without any visible output.
$SCREENSHOTThis executes the scrot command stored in the SCREENSHOT variable.
convert -scale 10% -blur 0x0.5 -resize 1000% $PICTURE $PICTUREThis applies some image processing effects to the screenshot stored in $PICTURE. Specifically, it scales the image down to 10% of its original size, applies a blur effect with a radius of 0.5 pixels, and then scales it back up to 1000% of its original size. The result is a blurred version of the original screenshot, which is then saved back to $PICTURE.
pkill i3lockThis kills any running instances of the i3lock program, which is the program responsible for locking the screen.
i3lock -i $PICTUREThis runs the i3lock program with the -i option to specify the image file to use as the lock screen wallpaper.
rm $PICTUREThis removes the temporary screenshot file from the /tmp directory.
JPG seems to be the fastest format (its almost 2 seconds faster than PNG)
← Back to blog