Rework lockhelper for gunter
All checks were successful
Run nix flake check / flake-check (push) Successful in 2m47s
Periodic flake update / flake-update (push) Successful in 2m10s

This commit is contained in:
2025-06-10 19:21:22 +02:00
parent 75064a7228
commit 8d419de159
4 changed files with 75 additions and 40 deletions

View File

@@ -1,7 +1,6 @@
{ pkgs, config, ... }:
{
imports = [
./lockhelper.nix
./noita-helper.nix
];
home.file.".local/bin/hl-no-opacity" = {

View File

@@ -1,14 +1,21 @@
{ pkgs, ... }:
let
lockhelper = pkgs.writeShellApplication {
name = "lockhelper";
runtimeInputs = with pkgs; [
grim
jq
];
text = (builtins.readFile ./lockhelper.sh);
};
in
{
home.packages = [ lockhelper ];
writeShellApplication,
grim,
jq,
gawk,
hyprland,
hyprlock,
procps,
}:
writeShellApplication {
name = "lockhelper";
runtimeInputs = [
grim
jq
gawk
hyprland
hyprlock
procps
];
text = (builtins.readFile ./lockhelper.sh);
}

View File

@@ -3,11 +3,14 @@ set -eo pipefail
mkdir -p /tmp/lockscreen || true
monitors=$(hyprctl monitors -j | jq -r '.[] | select( .name | contains ("DP")) | .name')
monitor_lines=$(hyprctl monitors -j | jq -r '.[] | select (.name | contains ("DP")) | [.name, .description]| @tsv')
while IFS= read -r m; do
grim -o "$m" "/tmp/lockscreen/$m.png" || true
done <<< "$monitors"
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)" ]