diff --git a/home/isabel/services/wayland/gtklock.nix b/home/isabel/services/wayland/gtklock.nix index 4befc50e4..d215abbef 100644 --- a/home/isabel/services/wayland/gtklock.nix +++ b/home/isabel/services/wayland/gtklock.nix @@ -20,16 +20,47 @@ in { config = { modules = [ "${pkgs.gtklock-powerbar-module.outPath}/lib/gtklock/powerbar-module.so" - "${pkgs.gtklock-playerctl-module}/lib/gtklock/playerctl-module.so" ]; style = pkgs.writeText "gtklock-style.css" '' window { - font-family: Product Sans; + background-size: cover; + background-repeat: no-repeat; + background-position: center; } + + + #clock-label { + margin-bottom: 30px; + font-size: 800%; + font-weight: bold; + color: white; + text-shadow: 0px 2px 10px rgba(0,0,0,.1) + } + + #body { + margin-top: 50px; + } + + #unlock-button { + all: unset; + color: transparent; + } + entry { - border-radius: 19px; - box-shadow: 0 1px 3px rgba(0,0,0,.1); + border-radius: 12px; + margin: 1px; + box-shadow: 1px 2px 4px rgba(0,0,0,.1) + } + + #input-label { + color: transparent; + margin: -20rem; + } + + #powerbar-box * { + border-radius: 12px; + box-shadow: 1px 2px 4px rgba(0,0,0,.1) } ''; }; diff --git a/modules/common/options/themes/default.nix b/modules/common/options/themes/default.nix index 045bf8a27..00fcf9c2f 100644 --- a/modules/common/options/themes/default.nix +++ b/modules/common/options/themes/default.nix @@ -58,7 +58,7 @@ in { theme = { package = mkOption { type = types.package; - default = pkgs.catppucin-kde.override { + default = pkgs.catppuccin-kde.override { flavour = ["mocha"]; accents = ["sapphire"]; winDecStyles = ["modern"]; diff --git a/modules/extra/shared/home-manager/gtklock/default.nix b/modules/extra/shared/home-manager/gtklock/default.nix index d215abbef..f95a15509 100644 --- a/modules/extra/shared/home-manager/gtklock/default.nix +++ b/modules/extra/shared/home-manager/gtklock/default.nix @@ -1,71 +1,101 @@ { - pkgs, - lib, config, - osConfig, + lib, + pkgs, ... }: -with lib; let - dev = osConfig.modules.device; - vid = osConfig.modules.system.video; - env = osConfig.modules.usrEnv; - - acceptedTypes = ["desktop" "laptop" "lite" "hybrid"]; -in { - config = mkIf ((builtins.elem dev.type acceptedTypes && env.screenLock == "gtklock") && (vid.enable && env.isWayland)) { - programs.gtklock = { - enable = true; - package = pkgs.gtklock; +with builtins; let + cfg = config.programs.gtklock; - config = { - modules = [ - "${pkgs.gtklock-powerbar-module.outPath}/lib/gtklock/powerbar-module.so" - ]; + inherit (lib) types mkIf mkOption mkEnableOption mkPackageOptionMD mdDoc literalExpression optionals optionalString; + inherit (lib.generators) toINI; - style = pkgs.writeText "gtklock-style.css" '' - window { - background-size: cover; - background-repeat: no-repeat; - background-position: center; - } + # the main config includes two very niche options: style (which takes a path) and modules, which takes a list of module paths + # concatted by ";" + # for type checking purposes, I prefer templating the main section of the config and let the user safely choose options + # extraConfig takes an attrset, and converts it to the correct INI format - it's mostly just strings and integers, so that's fine + baseConfig = '' + [main] + ${optionalString (cfg.config.gtk-theme != "") "gtk-theme=${cfg.config.gtk-theme}"} + ${optionalString (cfg.config.style != "") "style=${cfg.config.style}"} + ${optionalString (cfg.config.modules != []) "modules=${concatStringsSep ";" cfg.config.modules}"} + ''; + finalConfig = baseConfig + optionals (cfg.extraConfig != null) (toINI {} cfg.extraConfig); +in { + meta.maintainers = [maintainers.NotAShelf]; + options.programs.gtklock = { + enable = mkEnableOption "GTK-based lockscreen for Wayland"; + package = mkPackageOptionMD pkgs "gtklock" {}; - #clock-label { - margin-bottom: 30px; - font-size: 800%; - font-weight: bold; - color: white; - text-shadow: 0px 2px 10px rgba(0,0,0,.1) - } - - #body { - margin-top: 50px; - } - - #unlock-button { - all: unset; - color: transparent; - } - - entry { - border-radius: 12px; - margin: 1px; - box-shadow: 1px 2px 4px rgba(0,0,0,.1) - } + config = { + gtk-theme = mkOption { + type = types.str; + default = ""; + description = mdDoc '' + GTK theme to use for gtklock. + ''; + example = "Adwaita-dark"; + }; - #input-label { - color: transparent; - margin: -20rem; - } + style = mkOption { + type = with types; oneOf [str path]; + default = ""; + description = mdDoc '' + The css file to be used for gtklock. + ''; + example = literalExpression '' + pkgs.writeText "gtklock-style.css" ''' + window { + background-size: cover; + background-repeat: no-repeat; + background-position: center; + } + ''' + ''; + }; - #powerbar-box * { - border-radius: 12px; - box-shadow: 1px 2px 4px rgba(0,0,0,.1) - } + modules = mkOption { + type = with types; listOf (either package str); + default = []; + description = mdDoc '' + A list of gtklock modulesto use. Can either be packages, absolute paths, or strings. + ''; + example = literalExpression '' + [ + "${pkgs.gtklock-powerbar-module.outPath}/lib/gtklock/powerbar-module.so" + "${pkgs.gtklock-playerctl-module.outPath}/lib/gtklock/playerctl-module.so" + ]; ''; }; + }; - extraConfig = {}; + extraConfig = mkOption { + type = with types; nullOr attrs; + default = { + countdown = { + countdown-position = "top-right"; + justify = "right"; + countdown = 20; + }; + }; + description = mdDoc '' + Extra configuration to append to gtklock configuration file. + Mostly used for appending module configurations. + ''; + example = literalExpression '' + countdown = { + countdown-position = "top-right"; + justify = "right"; + countdown = 20; + } + ''; }; }; + + config = mkIf cfg.enable { + home.packages = [cfg.package]; + + xdg.configFile."gtklock/config.ini".source = pkgs.writeText "gtklock-config.ini" finalConfig; + }; }