#!/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