nixos/home/scripts/lockhelper.sh
Torjus Håkestad 8d419de159
All checks were successful
Run nix flake check / flake-check (push) Successful in 2m47s
Periodic flake update / flake-update (push) Successful in 2m10s
Rework lockhelper for gunter
2025-06-10 19:21:22 +02:00

22 lines
565 B
Bash

#!/usr/bin/env bash
set -eo pipefail
mkdir -p /tmp/lockscreen || true
monitor_lines=$(hyprctl monitors -j | jq -r '.[] | select (.name | contains ("DP")) | [.name, .description]| @tsv')
while IFS= read -r m; do
name=$(echo "$m" | awk -F $'\t' '{print $1}')
sum=$(echo "$m" | awk -F $'\t' '{printf $2}' | sha256sum | awk '{print substr($1,1,8)}')
grim -o "$name" "/tmp/lockscreen/$sum.png" || true
done <<< "$monitor_lines"
# Only lock if not already running
if [ -z "$(pgrep hyprlock)" ]
then
exec hyprlock
else
echo "Already locked"
fi