2024-02-05 06:25:43 -05:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
2024-06-27 00:56:27 -04:00
|
|
|
inherit (lib) getExe mkIf;
|
2024-02-05 06:25:43 -05:00
|
|
|
|
2024-06-27 00:56:27 -04:00
|
|
|
cfg = config.roles.desktop;
|
2024-05-29 12:30:14 -04:00
|
|
|
|
2024-06-27 00:56:27 -04:00
|
|
|
hmCfg = config.home-manager.users.${cfg.user};
|
2024-05-29 12:30:14 -04:00
|
|
|
agsPkg = hmCfg.programs.ags.finalPackage;
|
|
|
|
hyprPkg = hmCfg.wayland.windowManager.hyprland.finalPackage;
|
|
|
|
|
|
|
|
runInDesktop = pkgs.writeShellApplication {
|
|
|
|
name = "runInDesktop";
|
|
|
|
runtimeInputs = [
|
|
|
|
pkgs.sudo
|
|
|
|
agsPkg
|
|
|
|
hyprPkg
|
|
|
|
];
|
2024-06-12 12:56:11 -04:00
|
|
|
|
2024-05-29 12:30:14 -04:00
|
|
|
text = ''
|
2024-06-12 12:56:11 -04:00
|
|
|
params=( "$@" )
|
2024-06-27 00:56:27 -04:00
|
|
|
user="$(id -u ${cfg.user})"
|
2024-06-12 12:56:11 -04:00
|
|
|
readarray -t SIGS <<< "$(ls "/run/user/$user/hypr/")"
|
|
|
|
|
|
|
|
run() {
|
|
|
|
export HYPRLAND_INSTANCE_SIGNATURE="$1"
|
2024-06-27 00:56:27 -04:00
|
|
|
sudo -Eu ${cfg.user} hyprctl dispatch exec "''${params[@]}"
|
2024-06-12 12:56:11 -04:00
|
|
|
}
|
2024-05-29 12:30:14 -04:00
|
|
|
|
2024-06-12 12:56:11 -04:00
|
|
|
i=0
|
|
|
|
|
|
|
|
# FIXME: not sure if sudo passes the exit status to this
|
|
|
|
while ! run "''${SIGS[$i]}"; do
|
|
|
|
((i+=1))
|
|
|
|
done
|
2024-05-29 12:30:14 -04:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
lockPkg = pkgs.writeShellApplication {
|
|
|
|
name = "lock";
|
|
|
|
runtimeInputs = [
|
|
|
|
agsPkg
|
|
|
|
];
|
2024-06-12 12:56:11 -04:00
|
|
|
|
2024-05-29 12:30:14 -04:00
|
|
|
text = ''
|
|
|
|
ags -r 'Tablet.setLaptopMode()'
|
2024-06-27 00:56:27 -04:00
|
|
|
ags -b lockscreen -c /home/${cfg.user}/.config/ags/lockscreen.js
|
2024-05-29 12:30:14 -04:00
|
|
|
'';
|
|
|
|
};
|
2024-02-05 06:25:43 -05:00
|
|
|
in {
|
2024-06-27 00:56:27 -04:00
|
|
|
services.acpid = mkIf cfg.isLaptop {
|
2024-05-29 12:30:14 -04:00
|
|
|
enable = true;
|
|
|
|
|
2024-06-12 12:56:11 -04:00
|
|
|
lidEventCommands =
|
|
|
|
# bash
|
|
|
|
''
|
|
|
|
LID="/proc/acpi/button/lid/LID/state"
|
|
|
|
state=$(${pkgs.gawk}/bin/awk '{print $2}' "$LID")
|
|
|
|
|
|
|
|
case "$state" in
|
|
|
|
*open*)
|
2024-06-27 00:56:27 -04:00
|
|
|
${getExe runInDesktop} "ags -b lockscreen -r 'authFinger()'"
|
2024-06-12 12:56:11 -04:00
|
|
|
;;
|
|
|
|
|
|
|
|
*close*)
|
2024-06-27 00:56:27 -04:00
|
|
|
${getExe runInDesktop} ${getExe lockPkg}
|
2024-06-12 12:56:11 -04:00
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
logger -t lid-handler "Failed to detect lid state ($state)"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
'';
|
2024-05-29 12:30:14 -04:00
|
|
|
};
|
|
|
|
|
2024-06-27 00:56:27 -04:00
|
|
|
home-manager.users.${cfg.user} = {
|
2024-05-05 23:07:06 -04:00
|
|
|
home.packages = [
|
|
|
|
pkgs.gnome.seahorse
|
2024-04-19 20:31:17 -04:00
|
|
|
lockPkg
|
2024-02-21 17:21:57 -05:00
|
|
|
];
|
|
|
|
|
2024-02-05 06:25:43 -05:00
|
|
|
wayland.windowManager.hyprland = {
|
|
|
|
settings = {
|
2024-05-29 12:30:14 -04:00
|
|
|
exec-once = [
|
|
|
|
"gnome-keyring-daemon --start --components=secrets"
|
|
|
|
"${pkgs.plasma5Packages.polkit-kde-agent}/libexec/polkit-kde-authentication-agent-1"
|
|
|
|
];
|
2024-02-05 06:25:43 -05:00
|
|
|
|
|
|
|
windowrule = [
|
|
|
|
"float,^(org.kde.polkit-kde-authentication-agent-1)$"
|
|
|
|
"size 741 288,^(org.kde.polkit-kde-authentication-agent-1)$"
|
|
|
|
"center,^(org.kde.polkit-kde-authentication-agent-1)$"
|
2024-02-05 09:56:42 -05:00
|
|
|
|
|
|
|
# For GParted auth
|
|
|
|
"size 741 288,^(org.kde.ksshaskpass)$"
|
|
|
|
"move cursor -370 -144,^(org.kde.ksshaskpass)$"
|
2024-02-05 06:25:43 -05:00
|
|
|
];
|
|
|
|
|
|
|
|
bind = [
|
2024-06-27 00:56:27 -04:00
|
|
|
"$mainMod, L, exec, ${getExe lockPkg}"
|
2024-02-05 06:25:43 -05:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|