-
Notifications
You must be signed in to change notification settings - Fork 0
/
lock
executable file
·48 lines (39 loc) · 1.01 KB
/
lock
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
40
41
42
43
44
45
46
47
48
#!/bin/sh
set -e
# Define some paths
basePath="${HOME}/Pictures/Lockscreen";
lockPath="${basePath}/.lock";
imagePath="${basePath}/capture.png";
# Create the directory, if it doesn't exist
if [ ! -d "${basePath}" ]; then
mkdir -p $basePath;
fi;
#
# Take a screenshot, blur it, and use it as lockscreen.
#
lock() {
# Check to see if we are already doing something
if [ ! -f "${lockPath}" ]; then
echo "Locking screen...";
touch $lockPath;
screencapture -m $imagePath;
/usr/local/bin/convert $imagePath -scale 10% -scale 1000% $imagePath;
launchScreensaver;
rm -f $lockPath;
fi;
}
#
# The location of the screensaver app has changed in High Sierra
#
launchScreensaver() {
local name="ScreenSaverEngine";
local path;
if [[ "${OSTYPE}" == "darwin16" ]]; then
path="/System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/";
name="${name}.app";
else
path="/System/Library/CoreServices/ScreenSaverEngine.app/Contents/MacOS/";
fi;
open -a "${path}${name}";
}
lock;