nixos/home/scripts/lockhelper.sh

19 lines
384 B
Bash

#!/usr/bin/env bash
set -eo pipefail
mkdir -p /tmp/lockscreen || true
monitors=$(hyprctl monitors -j | jq -r '.[] | select( .name | contains ("DP")) | .name')
while IFS= read -r m; do
grim -o "$m" "/tmp/lockscreen/$m.png" || true
done <<< "$monitors"
# Only lock if not already running
if [ -z "$(pgrep hyprlock)" ]
then
exec hyprlock
else
echo "Already locked"
fi