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:
Torjus Håkestad 2025-06-10 19:21:22 +02:00
parent 75064a7228
commit 8d419de159
Signed by: torjus
SSH Key Fingerprint: SHA256:KjAds8wHfD2mBYK2H815s/+ABcSdcIHUndwHEdSxml4
4 changed files with 75 additions and 40 deletions

View File

@ -4,6 +4,25 @@
config, config,
... ...
}: }:
let
lockhelper = pkgs.callPackage ../scripts/lockhelper.nix { };
monitorTopDesc = "BNQ G2420HDBL T2B04424SL000";
monitorTopName = "desc:${monitorTopDesc}";
monitorTopHash = builtins.substring 0 8 (builtins.hashString "sha256" monitorTopDesc);
monitorLeftDesc = "Samsung Electric Company LS27A600U HNMT502389";
monitorLeftName = "desc:${monitorLeftDesc}";
monitorLeftHash = builtins.substring 0 8 (builtins.hashString "sha256" monitorLeftDesc);
monitorCenterDesc = "Acer Technologies XB271HU #ASPVEKfgZ8Dd";
monitorCenterName = "desc:${monitorCenterDesc}";
monitorCenterHash = builtins.substring 0 8 (builtins.hashString "sha256" monitorCenterDesc);
monitorRightDesc = "Samsung Electric Company LS27A600U HNMT502390";
monitorRightName = "desc:${monitorRightDesc}";
monitorRightHash = builtins.substring 0 8 (builtins.hashString "sha256" monitorRightDesc);
in
{ {
options.hyprland.enable = lib.mkEnableOption "Hyprland"; options.hyprland.enable = lib.mkEnableOption "Hyprland";
config = { config = {
@ -32,12 +51,12 @@
settings = { settings = {
general = { general = {
lock_cmd = "${pkgs.hyprlock}/bin/hyprlock"; lock_cmd = "${pkgs.hyprlock}/bin/hyprlock";
before_sleep_cmd = "lockhelper"; before_sleep_cmd = "${lockhelper}/bin/lockhelper";
ignore_dbus_inhibit = false; ignore_dbus_inhibit = false;
}; };
listener = { listener = {
timeout = 240; timeout = 240;
on-timeout = "lockhelper"; on-timeout = "${lockhelper}/bin/lockhelper";
}; };
}; };
}; };
@ -47,8 +66,10 @@
settings = { settings = {
background = [ background = [
{ {
monitor = "DP-5"; monitor = monitorTopName;
path = "/tmp/lockscreen/DP-5.png"; # path = "/tmp/lockscreen/${monitorTopHash}.png";
path = "screenshot";
color = "rgba(17, 17, 17, 1.0)";
blur_passes = 3; blur_passes = 3;
contrast = 0.8916; contrast = 0.8916;
brightness = 0.8172; brightness = 0.8172;
@ -56,8 +77,22 @@
vibrancy_darkness = 0.0; vibrancy_darkness = 0.0;
} }
{ {
monitor = "DP-6"; monitor = monitorLeftName;
path = "/tmp/lockscreen/DP-6.png"; # path = "/tmp/lockscreen/${monitorLeftHash}.png";
path = "screenshot";
color = "rgba(17, 17, 17, 1.0)";
blur_passes = 3;
contrast = 0.8916;
brightness = 0.8172;
vibrancy = 0.1696;
vibrancy_darkness = 0.0;
zindex = 1;
}
{
monitor = monitorCenterName;
# path = "/tmp/lockscreen/${monitorCenterHash}.png";
path = "screenshot";
color = "rgba(17, 17, 17, 1.0)";
blur_passes = 3; blur_passes = 3;
contrast = 0.8916; contrast = 0.8916;
brightness = 0.8172; brightness = 0.8172;
@ -65,17 +100,10 @@
vibrancy_darkness = 0.0; vibrancy_darkness = 0.0;
} }
{ {
monitor = "DP-7"; monitor = monitorRightName;
path = "/tmp/lockscreen/DP-7.png"; # path = "/tmp/lockscreen/${monitorRightHash}.png";
blur_passes = 3; path = "screenshot";
contrast = 0.8916; color = "rgba(17, 17, 17, 1.0)";
brightness = 0.8172;
vibrancy = 0.1696;
vibrancy_darkness = 0.0;
}
{
monitor = "DP-8";
path = "/tmp/lockscreen/DP-8.png";
blur_passes = 3; blur_passes = 3;
contrast = 0.8916; contrast = 0.8916;
brightness = 0.8172; brightness = 0.8172;
@ -85,9 +113,7 @@
]; ];
general = { general = {
no_fade_in = false;
grace = 0; grace = 0;
disable_loading_bar = true;
}; };
input-field = [ input-field = [
@ -155,10 +181,10 @@
"$term" = "kitty"; "$term" = "kitty";
# monitors # monitors
"$mon_top" = "desc:BNQ G2420HDBL T2B04424SL000"; "$mon_top" = monitorTopName;
"$mon_left" = "desc:Samsung Electric Company LS27A600U HNMT502389"; "$mon_left" = monitorLeftName;
"$mon_center" = "desc:Acer Technologies XB271HU #ASPVEKfgZ8Dd"; "$mon_center" = monitorCenterName;
"$mon_right" = "desc:Samsung Electric Company LS27A600U HNMT502390"; "$mon_right" = monitorRightName;
monitor = [ monitor = [
"$mon_top,1920x1080@60,2560x0,1" # top T2B04424SL000 "$mon_top,1920x1080@60,2560x0,1" # top T2B04424SL000
@ -269,7 +295,7 @@
"$mainMod,Return,exec,$term" "$mainMod,Return,exec,$term"
# hyprlock # hyprlock
"$shiftMainMod,l,exec,lockhelper" "$shiftMainMod,l,exec,${lockhelper}/bin/lockhelper"
# rofi # rofi
"$mainMod,D,exec,rofi-launcher" "$mainMod,D,exec,rofi-launcher"

View File

@ -1,7 +1,6 @@
{ pkgs, config, ... }: { pkgs, config, ... }:
{ {
imports = [ imports = [
./lockhelper.nix
./noita-helper.nix ./noita-helper.nix
]; ];
home.file.".local/bin/hl-no-opacity" = { 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 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 while IFS= read -r m; do
grim -o "$m" "/tmp/lockscreen/$m.png" || true name=$(echo "$m" | awk -F $'\t' '{print $1}')
done <<< "$monitors" 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 # Only lock if not already running
if [ -z "$(pgrep hyprlock)" ] if [ -z "$(pgrep hyprlock)" ]