-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlock.sh
executable file
·39 lines (29 loc) · 1.08 KB
/
lock.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# Lockscreen script
# check if convert (image magick) is installed
if [ -z $(which convert) ]; then
echo 'You need to install ImageMagick'
echo "This needs the command 'convert' from it."
exit 1
fi
STORAGE_DIR=${HOME}'/tmp/screenshots'
test -e ${STORAGE_DIR} || mkdir -p ${STORAGE_DIR}
# remove old screen
rm -r ${STORAGE_DIR}/screen.png
# take a screenshot
screencapture ${STORAGE_DIR}/screen.png
# cd into screenshots
cd ${STORAGE_DIR}/
# blur the image
# com.apple.desktop.admin.png is the name for the login screen
convert -resize 5% screen.png screensized.png
convert -resize 1000% screensized.png com.apple.desktop.admin.png
# backup old lock screen picture
# check if it already exists to not overwrite
if [ ! -f ${STORAGE_DIR}/bak.png ]; then
cp /Library/Caches/com.apple.desktop.admin.png ${STORAGE_DIR}/bak.png
fi
# replace the old lock screen picture with the new blurred one
cp com.apple.desktop.admin.png /Library/Caches/com.apple.desktop.admin.png
# lock the screen
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend