hyprlock/nix/hm-module.nix

238 lines
5.9 KiB
Nix
Raw Normal View History

2024-02-19 00:50:56 +01:00
self: {
config,
pkgs,
lib,
...
}: let
inherit (builtins) toString;
2024-02-20 06:21:38 +01:00
inherit (lib.types) int listOf package str bool submodule;
2024-02-19 00:50:56 +01:00
inherit (lib.modules) mkIf;
inherit (lib.options) mkOption mkEnableOption;
cfg = config.programs.hyprlock;
2024-02-19 00:50:56 +01:00
in {
options.programs.hyprlock = {
2024-02-19 00:50:56 +01:00
enable = mkEnableOption "Hyprlock, Hyprland's GPU-accelerated lock screen utility";
package = mkOption {
description = "The hyprlock package";
type = package;
default = self.packages.${pkgs.stdenv.hostPlatform.system}.hyprlock;
};
backgrounds = mkOption {
description = "Monitor configurations";
2024-02-20 06:21:38 +01:00
default = [
{
monitor = "";
path = "";
}
];
2024-02-19 00:50:56 +01:00
type = listOf (submodule {
options = {
monitor = mkOption {
description = "The monitor to apply the given wallpaper to";
type = str;
default = "";
};
path = mkOption {
description = "The path to the wallpaper";
type = str;
default = "echo 'timeout reached'";
};
};
});
};
general.disable_loading_bar =
mkEnableOption ""
// {
description = "Whether to disable loading bar";
};
2024-02-20 06:21:38 +01:00
input_field = {
monitor = mkOption {
description = "The monitor to place the input field on";
type = str;
default = "";
};
2024-02-19 00:50:56 +01:00
2024-02-20 06:21:38 +01:00
size = {
width = mkOption {
description = "Width of the input field";
type = int;
default = 200;
};
height = mkOption {
description = "Height of the input field";
type = int;
default = 50;
2024-02-19 00:50:56 +01:00
};
2024-02-20 06:21:38 +01:00
};
outline_thickness = mkOption {
description = "The outline thickness of the input field";
type = int;
default = 3;
};
outer_color = mkOption {
description = "The outer color of the input field";
type = str;
default = "rgb(151515)";
};
inner_color = mkOption {
description = "The inner color of the input field";
type = str;
default = "rgb(200, 200, 200)";
};
font_color = mkOption {
description = "The font color of the input field";
type = str;
default = "rgb(10, 10, 10)";
};
fade_on_empty = mkOption {
description = "Fade input field when empty";
type = bool;
default = true;
};
placeholder_text = mkOption {
description = "The placeholder text of the input field";
type = str;
default = "<i>Input Password...</i>";
};
2024-02-19 00:50:56 +01:00
2024-02-20 06:21:38 +01:00
position = {
x = mkOption {
description = "X position of the label";
type = int;
default = 0;
};
y = mkOption {
description = "Y position of the label";
2024-02-19 00:50:56 +01:00
type = int;
2024-02-20 06:21:38 +01:00
default = 80;
2024-02-19 00:50:56 +01:00
};
2024-02-20 06:21:38 +01:00
};
halign = mkOption {
description = "Horizontal alignment of the label";
type = str;
default = "center";
};
2024-02-19 00:50:56 +01:00
2024-02-20 06:21:38 +01:00
valign = mkOption {
description = "Vertical alignment of the label";
type = str;
default = "center";
};
};
label = {
monitor = mkOption {
description = "The monitor to display the label on";
type = str;
default = "";
};
text = mkOption {
description = "Text to display in label";
type = str;
default = "Hi there, $USER";
};
color = mkOption {
description = "Color of the label";
type = str;
default = "rgba(200, 200, 200, 1.0)";
};
font_size = mkOption {
description = "Font size of the label";
type = int;
default = 25;
};
font_family = mkOption {
description = "Font family of the label";
type = str;
default = "Noto Sans";
};
position = {
x = mkOption {
description = "X position of the label";
type = int;
default = 0;
2024-02-19 00:50:56 +01:00
};
2024-02-20 06:21:38 +01:00
y = mkOption {
description = "Y position of the label";
type = int;
default = 80;
2024-02-19 00:50:56 +01:00
};
};
2024-02-20 06:21:38 +01:00
halign = mkOption {
description = "Horizontal alignment of the label";
type = str;
default = "center";
};
valign = mkOption {
description = "Vertical alignment of the label";
type = str;
default = "center";
};
2024-02-19 00:50:56 +01:00
};
};
config = mkIf cfg.enable {
xdg.configFile."hypr/hyprlock.conf".text = ''
general {
2024-02-20 06:21:38 +01:00
disable_loading_bar = ${toString cfg.general.disable_loading_bar}
2024-02-19 00:50:56 +01:00
}
2024-02-20 06:21:38 +01:00
label {
monitor = ${cfg.label.monitor}
text = ${cfg.label.text}
color = ${cfg.label.color}
font_size = ${toString cfg.label.font_size}
font_family = ${cfg.label.font_family}
position = ${toString cfg.label.position.x} ${toString cfg.label.position.y}
halign = ${cfg.label.halign}
valign = ${cfg.label.valign}
}
input-field {
2024-02-19 00:50:56 +01:00
monitor = ${cfg.input_field.monitor}
size = ${toString cfg.input_field.size.width} ${toString cfg.input_field.size.height}
outline_thickness = ${toString cfg.input_field.outline_thickness}
outer_color = ${cfg.input_field.outer_color}
inner_color = ${cfg.input_field.inner_color}
2024-02-20 06:21:38 +01:00
font_color = ${cfg.input_field.font_color}
fade_on_empty = ${toString cfg.input_field.fade_on_empty}
placeholder-text = ${cfg.input_field.placeholder_text}
position = ${toString cfg.input_field.position.x} ${toString cfg.input_field.position.y}
halign = ${cfg.input_field.halign}
valign = ${cfg.input_field.valign}
2024-02-19 00:50:56 +01:00
}
${builtins.concatStringsSep "\n" (map (background: ''
background {
monitor = ${background.monitor}
path = ${background.path}
}
'')
cfg.backgrounds)}
'';
};
}