aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/idlechecker33
-rwxr-xr-xbin/pretty-lock27
2 files changed, 59 insertions, 1 deletions
diff --git a/bin/idlechecker b/bin/idlechecker
index 36261e9..197d534 100755
--- a/bin/idlechecker
+++ b/bin/idlechecker
@@ -1,6 +1,37 @@
#!/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
+
+
# xss-lock -- ./pretty-lock &
swayidle -w \
timeout 300 '~/bin/pretty-lock' \
- before-sleep '~/bin/pretty-lock'
+ timeout 500 'swaymsg "output * dpms off"' \
+ resume 'swaymsg "output * dpms on"' \
+ before-sleep 'swaymsg "output * dpms off"' \
+ before-sleep '~/bin/pretty-lock'
diff --git a/bin/pretty-lock b/bin/pretty-lock
index 8ef40e0..48918f6 100755
--- a/bin/pretty-lock
+++ b/bin/pretty-lock
@@ -1,5 +1,32 @@
#!/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 \