-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlockscreen.sh
executable file
·42 lines (34 loc) · 968 Bytes
/
lockscreen.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
40
41
42
#!/usr/bin/env bash
FILEPATH="/tmp/screen.png"
FILEPATH_LOCK="/tmp/lockscreen.png"
IS_i3_RUNNING=false
IS_SWAY_RUNNING=false
#Check if i3 or sway are running
if [ $(ps -ef | grep "i3 " | grep -v grep | wc -l) -gt 1 ]; then
IS_i3_RUNNING=true
elif [ $(ps -ef | grep sway | grep -v grep | wc -l) -gt 1 ]; then
IS_SWAY_RUNNING=true
else
>&2 echo "Could not find i3 or sway running on the system"
fi
#retrieve screenshot
if $IS_i3_RUNNING; then
import -window root $FILEPATH
elif $IS_SWAY_RUNNING; then
grim -t png $FILEPATH
fi
if [ -z $XDG_CONFIG_HOME ]; then
XDG_CONFIG_HOME=$HOME/.config
fi
$XDG_CONFIG_HOME/sway/scripts/fourier -input-file $FILEPATH \
-output-file $FILEPATH_LOCK \
-radius 0.2 \
#mute all audio
amixer -q sset Master,0 mute
#lock the screen
if $IS_i3_RUNNING; then
i3lock --image=$FILEPATH_LOCK
elif $IS_SWAY_RUNNING; then
swaylock --scaling fill --image $FILEPATH_LOCK
fi
rm $FILEPATH