From 82ef35ed340702a32faceb812f76e706cc435f50 Mon Sep 17 00:00:00 2001 From: ~noodlez1232 Date: Thu, 26 Sep 2024 14:14:56 -0700 Subject: [PATCH] waylogout: added configuration module 90% of the code is copied over from swaylock so thanks to the creator of that module! --- modules/lib/maintainers.nix | 6 ++++ modules/modules.nix | 1 + modules/programs/waylogout.nix | 56 ++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 modules/programs/waylogout.nix diff --git a/modules/lib/maintainers.nix b/modules/lib/maintainers.nix index 91ecb47be228..5c9e21734359 100644 --- a/modules/lib/maintainers.nix +++ b/modules/lib/maintainers.nix @@ -628,4 +628,10 @@ keys = [{ fingerprint = "BC82 4BB5 1656 D144 285E A0EC D382 C4AF EECE AA90"; }]; }; + noodlez = { + name = "Nathaniel Barragan"; + email = "contact@nathanielbarragan.xyz"; + github = "Noodlez1232"; + githubId = 12480453; + }; } diff --git a/modules/modules.nix b/modules/modules.nix index 5d40a82fc8f5..3ed7b5576a8c 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -255,6 +255,7 @@ let ./programs/pywal.nix ./programs/rbenv.nix ./programs/watson.nix + ./programs/waylogout.nix ./programs/waybar.nix ./programs/wezterm.nix ./programs/wlogout.nix diff --git a/modules/programs/waylogout.nix b/modules/programs/waylogout.nix new file mode 100644 index 000000000000..fff4f27a62d9 --- /dev/null +++ b/modules/programs/waylogout.nix @@ -0,0 +1,56 @@ +{ pkgs, config, lib, ... }: + +with lib; + +let cfg = config.programs.waylogout; +in { + meta.maintainers = [ hm.maintainers.noodlez ]; + + options.programs.waylogout = { + enable = mkOption { + default = false; + type = lib.types.bool; + example = true; + description = '' + Whether or not to enable waylogout. + ''; + }; + + package = mkPackageOption pkgs "waylogout" { }; + + settings = mkOption { + type = with types; attrsOf (oneOf [ bool float int str ]); + default = { }; + description = '' + Default arguments to {command}`waylogout`. An empty set + disables configuration generation. + ''; + example = { + color = "808080"; + poweroff-command = "systemctl poweroff"; + reboot-command = "systemctl reboot"; + scaling = "fit"; + effect-blur = "7x4"; + screenshots = true; + }; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "programs.waylogout" pkgs + lib.platforms.linux) + ]; + + home.packages = [ cfg.package ]; + + xdg.configFile."waylogout/config" = mkIf (cfg.settings != { }) { + text = concatStrings (mapAttrsToList (n: v: + if v == false then + "" + else + (if v == true then n else n + "=" + builtins.toString v) + "\n") + cfg.settings); + }; + }; +}