aboutsummaryrefslogtreecommitdiff
path: root/bin/pretty-lock
blob: 48918f677776205fbcb1d0a33cfbd8b1ca085c7d (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
45
#!/bin/sh

LOCKFILE="$HOME/.local/state/algo/swayidle.lock"
LOCKDIR="$(dirname "$LOCKFILE")"

# Ensure the directory exists
mkdir -p "$LOCKDIR"

# Check if lockfile exists and process is running
if [ -e "$LOCKFILE" ]; then
    LOCKPID=$(cat "$LOCKFILE")
    if kill -0 "$LOCKPID" 2>/dev/null; then
        echo "swayidle is already running with PID $LOCKPID"
        exit 1
    else
        echo "Stale lockfile found. Removing."
        rm -f "$LOCKFILE"
    fi
fi

# Create lockfile with current PID
echo $$ > "$LOCKFILE"

# Function to clean up on exit
cleanup() {
    rm -f "$LOCKFILE"
}
trap cleanup EXIT

swaylock \
    -f \
	--screenshots \
	--clock \
	--indicator \
	--indicator-radius 100 \
	--indicator-thickness 7 \
	--effect-blur 7x5 \
	--effect-vignette 0.5:0.5 \
	--ring-color bb00cc \
	--key-hl-color 880033 \
	--line-color 00000000 \
	--inside-color 00000088 \
	--separator-color 00000000 \
	--grace 2 \
	--fade-in 1