flocon/modules/programs/wlogout.nix
Anthony Rodriguez fc876b2ea5
treewide: update options API
The options API has been updated, in order for a more flexible setup
with `local.modules.desktop.enable` being replaced with an enum of
desktops at `local.systemVars.desktop`, which allows for switching
desktop environments by changing a single option. This is so that we can
switch to cosmic and only enable the programs we need (i.e. disable
greetd because we use cosmic-greeter and enable terminals since that is
desktop related). This is simpler than having a different module per
desktop.
2025-02-06 18:47:01 +01:00

75 lines
1.8 KiB
Nix

{
lib,
pkgs,
config,
...
}: let
inherit (config.local.systemVars) username;
mkLayout = items: let
formatItem = item: ''
{
"label" : "${item.label}",
"action" : "${item.action}",
"text" : "${item.text}",
"keybind" : "${item.keybind}"
}'';
in
builtins.concatStringsSep "\n" (map formatItem items);
in {
config = lib.mkIf (config.local.systemVars.desktop == "Hyprland") {
hjem.users.${username} = {
packages = [pkgs.wlogout];
files = {
".config/wlogout/layout".text = let
loginctl = lib.getExe' pkgs.systemd "loginctl";
systemctl = lib.getExe' pkgs.systemd "systemctl";
in
mkLayout [
{
action = "${loginctl} lock-session";
keybind = "l";
label = "lock";
text = "Lock";
}
{
action = "${systemctl} hibernate";
keybind = "h";
label = "hibernate";
text = "Hibernate";
}
{
action = "${loginctl} terminate-user ${username}";
keybind = "q";
label = "logout";
text = "Logout";
}
{
action = "${systemctl} poweroff";
keybind = "p";
label = "shutdown";
text = "Shutdown";
}
{
action = "${systemctl} suspend";
keybind = "s";
label = "suspend";
text = "Suspend";
}
{
action = "${systemctl} reboot";
keybind = "r";
label = "reboot";
text = "Reboot";
}
];
};
};
};
}