feat(hypr wim): hypridle -> acpid
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
Updater 2024-05-29 12:30:14 -04:00
parent bd5b0dcec8
commit a72a054632
5 changed files with 69 additions and 122 deletions

View file

@ -467,7 +467,7 @@
},
"flake-utils_2": {
"inputs": {
"systems": "systems_7"
"systems": "systems_5"
},
"locked": {
"lastModified": 1710146030,
@ -815,37 +815,15 @@
"type": "github"
}
},
"hypridle": {
"inputs": {
"hyprlang": "hyprlang",
"nixpkgs": [
"nixpkgs"
],
"systems": "systems_5"
},
"locked": {
"lastModified": 1716309977,
"narHash": "sha256-4jDQIcMDSFOOMBxVTEiC6Ck1vdc0kAFvv+StxnnE59Q=",
"owner": "hyprwm",
"repo": "hypridle",
"rev": "cb169c4e06cec9b4349e3668427e729d22328a54",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hypridle",
"type": "github"
}
},
"hyprland": {
"inputs": {
"hyprcursor": "hyprcursor",
"hyprlang": "hyprlang_2",
"hyprlang": "hyprlang",
"hyprwayland-scanner": "hyprwayland-scanner",
"nixpkgs": [
"nixpkgs"
],
"systems": "systems_6",
"systems": "systems_4",
"xdph": "xdph"
},
"locked": {
@ -892,28 +870,6 @@
}
},
"hyprlang": {
"inputs": {
"nixpkgs": [
"hypridle",
"nixpkgs"
],
"systems": "systems_4"
},
"locked": {
"lastModified": 1713121246,
"narHash": "sha256-502X0Q0fhN6tJK7iEUA8CghONKSatW/Mqj4Wappd++0=",
"owner": "hyprwm",
"repo": "hyprlang",
"rev": "78fcaa27ae9e1d782faa3ff06c8ea55ddce63706",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hyprlang",
"type": "github"
}
},
"hyprlang_2": {
"inputs": {
"nixpkgs": [
"hyprland",
@ -1892,7 +1848,6 @@
"headscale": "headscale",
"home-manager": "home-manager",
"hypr-official-plugins": "hypr-official-plugins",
"hypridle": "hypridle",
"hyprland": "hyprland",
"jellyfin-flake": "jellyfin-flake",
"jellyfin-ultrachromic-src": "jellyfin-ultrachromic-src",
@ -2132,36 +2087,6 @@
}
},
"systems_5": {
"locked": {
"lastModified": 1689347949,
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
"owner": "nix-systems",
"repo": "default-linux",
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default-linux",
"type": "github"
}
},
"systems_6": {
"locked": {
"lastModified": 1689347949,
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
"owner": "nix-systems",
"repo": "default-linux",
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default-linux",
"type": "github"
}
},
"systems_7": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
@ -2176,7 +2101,7 @@
"type": "github"
}
},
"systems_8": {
"systems_6": {
"locked": {
"lastModified": 1689347949,
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
@ -2308,7 +2233,7 @@
"nixpkgs": [
"nixpkgs"
],
"systems": "systems_8"
"systems": "systems_6"
},
"locked": {
"lastModified": 1716199546,

View file

@ -1,4 +1,5 @@
# Do not modify! This file is generated.
{
inputs = {
Hyprspace = {
@ -116,12 +117,6 @@
repo = "hyprland-plugins";
type = "github";
};
hypridle = {
inputs.nixpkgs.follows = "nixpkgs";
owner = "hyprwm";
repo = "hypridle";
type = "github";
};
hyprland = {
inputs.nixpkgs.follows = "nixpkgs";
submodules = true;
@ -339,4 +334,4 @@
};
};
outputs = inputs: inputs.flakegen ./flake.in.nix inputs;
}
}

View file

@ -142,11 +142,6 @@ let
repo = "Hyprspace";
};
hypridle = mkDep {
owner = "hyprwm";
repo = "hypridle";
};
grim-hyprland = mkDep {
owner = "eriedaberrie";
repo = "grim-hyprland";

View file

@ -207,9 +207,10 @@ const on_finished = () => {
lock.connect('finished', on_finished);
if (Vars.hasFprintd) {
Utils.authenticate('')
globalThis.authFinger = () => Utils.authenticate('')
.then(() => unlock())
.catch(logError);
globalThis.authFinger();
}

View file

@ -1,14 +1,44 @@
{
config,
hypridle,
lib,
pkgs,
...
}: let
inherit (lib) mkIf optionals;
inherit (lib) mkIf;
inherit (config.vars) mainUser;
isLaptop = config.services.logind.lidSwitch == "lock";
hmCfg = config.home-manager.users.${mainUser};
agsPkg = hmCfg.programs.ags.finalPackage;
hyprPkg = hmCfg.wayland.windowManager.hyprland.finalPackage;
runInDesktop = pkgs.writeShellApplication {
name = "runInDesktop";
runtimeInputs = [
pkgs.sudo
agsPkg
hyprPkg
];
text = ''
user="$(id -u ${mainUser})"
sig="$(ls "/run/user/$user/hypr/")"
export HYPRLAND_INSTANCE_SIGNATURE="$sig"
sudo -Eu ${mainUser} hyprctl dispatch exec "$@"
'';
};
lockPkg = pkgs.writeShellApplication {
name = "lock";
runtimeInputs = [
agsPkg
];
text = ''
ags -r 'Tablet.setLaptopMode()'
ags -b lockscreen -c /home/${mainUser}/.config/ags/lockscreen.js
'';
};
in {
imports = [
../greetd
@ -16,40 +46,41 @@ in {
services.gnome.gnome-keyring.enable = true;
home-manager.users.${mainUser} = let
hmCfg = config.home-manager.users.${mainUser};
lockPkg = pkgs.writeShellApplication {
name = "lock";
runtimeInputs = [
hmCfg.programs.ags.finalPackage
];
text = ''
ags -r 'Tablet.setLaptopMode()'
ags -b lockscreen -c /home/${mainUser}/.config/ags/lockscreen.js
'';
};
in {
services.acpid = mkIf isLaptop {
enable = true;
lidEventCommands = ''
LID="/proc/acpi/button/lid/LID/state"
state=$(cat "$LID" | ${pkgs.gawk}/bin/awk '{print $2}')
case "$state" in
*open*)
${runInDesktop}/bin/runInDesktop "ags -b lockscreen -r 'authFinger()'"
;;
*close*)
${runInDesktop}/bin/runInDesktop ${lockPkg}/bin/lock
;;
*)
logger -t lid-handler "Failed to detect lid state ($state)"
;;
esac
'';
};
home-manager.users.${mainUser} = {
home.packages = [
pkgs.gnome.seahorse
lockPkg
];
services.hypridle = mkIf isLaptop {
enable = true;
package = hypridle.packages.${pkgs.system}.default;
settings.general.lock_cmd = "${lockPkg}/bin/lock";
};
wayland.windowManager.hyprland = {
settings = {
exec-once =
[
"gnome-keyring-daemon --start --components=secrets"
"${pkgs.plasma5Packages.polkit-kde-agent}/libexec/polkit-kde-authentication-agent-1"
]
++ optionals isLaptop [
"systemctl --user restart hypridle"
];
exec-once = [
"gnome-keyring-daemon --start --components=secrets"
"${pkgs.plasma5Packages.polkit-kde-agent}/libexec/polkit-kde-authentication-agent-1"
];
windowrule = [
"float,^(org.kde.polkit-kde-authentication-agent-1)$"