Add kscreenlocker module (#221)

This commit is contained in:
magnouvean 2024-06-20 18:39:59 +02:00 committed by GitHub
parent 0537704f79
commit ef64e5da3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 113 additions and 37 deletions

View File

@ -30,6 +30,7 @@ At the moment `plasma-manager` supports configuring the following:
- Shortcuts (via the `shortcuts` module)
- Hotkeys (via the `hotkeys` module)
- Panels (via the `panels` module)
- Screen locker (via the `kscreenlocker` module)
- Fonts (via the `fonts` module)
- KDE apps (via the `apps` module). In particular the following kde apps have
modules in `plasma-manager`:

30
lib/wallpapers.nix Normal file
View File

@ -0,0 +1,30 @@
{ lib, ... }:
{
wallpaperPictureOfTheDayType = with lib.types; submodule {
options = {
provider = lib.mkOption {
type = nullOr (enum [ "apod" "bing" "flickr" "natgeo" "noaa" "wcpotd" "epod" "simonstalenhag" ]);
description = "The provider for the Picture of the Day plugin.";
};
updateOverMeteredConnection = lib.mkOption {
type = bool;
default = false;
description = "Whether to update the wallpaper on a metered connection.";
};
};
};
wallpaperSlideShowType = with lib.types; submodule {
options = {
path = lib.mkOption {
type = either path (listOf path);
description = "The path(s) where the wallpapers are located.";
};
interval = lib.mkOption {
type = int;
default = 300;
description = "The length between wallpaper switches.";
};
};
};
}

View File

@ -2,17 +2,18 @@
{
imports = [
./apps
./files.nix
./fonts.nix
./hotkeys.nix
./kscreenlocker.nix
./kwin.nix
./panels.nix
./shortcuts.nix
./spectacle.nix
./startup.nix
./windows.nix
./workspace.nix
./kwin.nix
./startup.nix
./panels.nix
./fonts.nix
./apps
];
options.programs.plasma.enable = lib.mkEnableOption ''

71
modules/kscreenlocker.nix Normal file
View File

@ -0,0 +1,71 @@
{ config, pkgs, lib, ... }:
let
cfg = config.programs.plasma;
inherit (import ../lib/wallpapers.nix { inherit lib; }) wallpaperPictureOfTheDayType wallpaperSlideShowType;
in
{
options.programs.plasma.kscreenlocker = {
wallpaper = lib.mkOption {
type = with lib.types; nullOr path;
default = null;
example = "${pkgs.kdePackages.plasma-workspace-wallpapers}/share/wallpapers/Kay/contents/images/1080x1920.png";
description = ''
The wallpaper for the lockscreen. Can be either be the path to an image file or a kpackage.
'';
};
wallpaperPictureOfTheDay = lib.mkOption {
type = lib.types.nullOr wallpaperPictureOfTheDayType;
default = null;
example = { provider = "apod"; };
description = ''
Allows you to set wallpaper using the picture of the day plugin. Needs the provider.
'';
};
wallpaperSlideShow = lib.mkOption {
type = lib.types.nullOr wallpaperSlideShowType;
default = null;
example = { path = "${pkgs.kdePackages.plasma-workspace-wallpapers}/share/wallpapers/"; };
description = ''
Allows you to set wallpaper using the slideshow plugin. Needs the path
to at least one directory.
'';
};
};
config = {
assertions = [
{
assertion =
let
wallpapers = with cfg.workspace; [ wallpaperSlideShow wallpaper wallpaperPictureOfTheDay ];
in
lib.count (x: x != null) wallpapers <= 1;
message = "Can set only one of wallpaper, wallpaperSlideShow and wallpaperPictureOfTheDay for kscreenlocker.";
}
];
programs.plasma.configFile.kscreenlockerrc = (lib.mkMerge [
(lib.mkIf (cfg.kscreenlocker.wallpaper != null) {
Greeter.WallpaperPlugin = "org.kde.image";
"Greeter/Wallpaper/org.kde.image/General".Image = cfg.kscreenlocker.wallpaper;
})
(lib.mkIf (cfg.kscreenlocker.wallpaperPictureOfTheDay != null) {
Greeter.WallpaperPlugin = "org.kde.potd";
"Greeter/Wallpaper/org.kde.potd/General" = {
Provider = cfg.kscreenlocker.wallpaperPictureOfTheDay.provider;
UpdateOverMeteredConnection = with cfg.kscreenlocker.wallpaperPictureOfTheDay;
(lib.mkIf (updateOverMeteredConnection != null) (if updateOverMeteredConnection then 1 else 0));
};
})
(lib.mkIf (cfg.kscreenlocker.wallpaperSlideShow != null) {
Greeter.WallpaperPlugin = "org.kde.slideshow";
"Greeter/Wallpaper/org.kde.slideshow/General" = {
SlidePaths = with cfg.kscreenlocker.wallpaperSlideShow;
(if ((builtins.isPath path) || (builtins.isString path)) then
(builtins.toString cfg.kscreenlocker.wallpaperSlideShow.path) else
(builtins.concatStringsSep "," cfg.kscreenlocker.wallpaperSlideShow.path));
SlideInterval = cfg.kscreenlocker.wallpaperSlideShow.interval;
};
})
]);
};
}

View File

@ -167,9 +167,9 @@ in
var desktop = allDesktops[desktopIndex];
desktop.wallpaperPlugin = "org.kde.slideshow";
desktop.currentConfigGroup = Array("Wallpaper", "org.kde.slideshow", "General");
desktop.writeConfig("SlidePaths", ${if (builtins.isPath cfg.workspace.wallpaperSlideShow.path) then
"\"" + cfg.workspace.wallpaperSlideShow.path + "\"" else
"[" + (builtins.concatStringsSep "," (map (s: "\"" + s + "\"") cfg.workspace.wallpaperSlideShow.path)) + "]"});
desktop.writeConfig("SlidePaths", ${with cfg.workspace.wallpaperSlideShow; if ((builtins.isPath path) || (builtins.isString path)) then
"\"" + (builtins.toString path) + "\"" else
"[" + (builtins.concatStringsSep "," (map (s: "\"" + s + "\"") path)) + "]"});
desktop.writeConfig("SlideInterval", "${builtins.toString cfg.workspace.wallpaperSlideShow.interval}");
}
'' else "");

View File

@ -3,34 +3,7 @@
let
cfg = config.programs.plasma;
wallpaperSlideShowType = with lib.types; submodule {
options = {
path = lib.mkOption {
type = either path (listOf path);
description = "The path(s) where the wallpapers are located.";
};
interval = lib.mkOption {
type = int;
default = 300;
description = "The length between wallpaper switches.";
};
};
};
wallpaperPictureOfTheDayType = with lib.types; submodule {
options = {
provider = lib.mkOption {
type = nullOr (enum [ "apod" "bing" "flickr" "natgeo" "noaa" "wcpotd" "epod" "simonstalenhag" ]);
description = "The provider for the Picture of the Day plugin.";
};
updateOverMeteredConnection = lib.mkOption {
type = bool;
default = false;
description = "Whether to update the wallpaper on a metered connection.";
};
};
};
inherit (import ../lib/wallpapers.nix { inherit lib; }) wallpaperPictureOfTheDayType wallpaperSlideShowType;
cursorType = with lib.types; submodule {
options = {
@ -137,7 +110,7 @@ in
wallpaperSlideShow = lib.mkOption {
type = lib.types.nullOr wallpaperSlideShowType;
default = null;
example = "${pkgs.kdePackages.plasma-workspace-wallpapers}/share/wallpapers/";
example = { path = "${pkgs.kdePackages.plasma-workspace-wallpapers}/share/wallpapers/"; };
description = ''
Allows you to set wallpaper slideshow. Needs a directory of your wallpapers and an interval length.
'';