summaryrefslogtreecommitdiff
path: root/scripts/gui/sslock
blob: 16cf125824d7d3181f3863a41875bffd900133b0 (plain)
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
#!/bin/sh

. "lib_common.sh"
. "lib_handle.sh"

help() {
cat << EOF
${progname}: Lock screen
options:
 -n              Black screen lock
 -h              Print this message and exit
EOF
exit 0
}

trap 'rm -f "${lock_image}"' EXIT INT TERM HUP

if [ "${#}" -eq 1 ]; then
	[ "${1}" = "-h" ] && help
	[ "${1}" = "-n" ] || invalid_use
	screenlock_handle
	exit 0
fi

[ "${#}" -ne 0 ] && invalid_use

mode=$(printf "Blank\nBlur\nWallpaper" | menu_handle default)
if [ "${mode}" = "Blank" ]; then
	screenlock_handle
	exit 0
fi

lock_image=$(get_random_filename .png)
if [ "${mode}" = "Blur" ]; then
	screenshot_handle fullscreen "${lock_image}"
	image_handle blur "${lock_image}"
fi

if [ "${mode}" = "Wallpaper" ]; then
	current_wallpaper="${XDG_CACHE_HOME:-$HOME/.cache}/wallpaper/current"
	cp "${current_wallpaper}" "${lock_image}"
fi

screenlock_handle "${lock_image}"