2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
2024-05-15 15:35:15 +00:00
|
|
|
inherit (lib) mkOption types;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
xcfg = config.services.xserver;
|
|
|
|
cfg = xcfg.desktopManager;
|
|
|
|
|
|
|
|
# If desktop manager `d' isn't capable of setting a background and
|
|
|
|
# the xserver is enabled, `feh' or `xsetroot' are used as a fallback.
|
|
|
|
needBGCond = d: ! (d ? bgSupport && d.bgSupport) && xcfg.enable;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
# Note: the order in which desktop manager modules are imported here
|
|
|
|
# determines the default: later modules (if enabled) are preferred.
|
|
|
|
# E.g., if Plasma 5 is enabled, it supersedes xterm.
|
|
|
|
imports = [
|
2024-04-21 15:54:59 +00:00
|
|
|
./none.nix ./xterm.nix ./phosh.nix ./xfce.nix ./plasma5.nix ../../desktop-managers/plasma6.nix ./lumina.nix
|
2022-02-10 20:34:41 +00:00
|
|
|
./lxqt.nix ./enlightenment.nix ./gnome.nix ./retroarch.nix ./kodi.nix
|
2020-04-24 23:36:52 +00:00
|
|
|
./mate.nix ./pantheon.nix ./surf-display.nix ./cde.nix
|
2024-04-21 15:54:59 +00:00
|
|
|
./cinnamon.nix ./budgie.nix ./deepin.nix ../../desktop-managers/lomiri.nix
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.xserver.desktopManager = {
|
|
|
|
|
|
|
|
wallpaper = {
|
|
|
|
mode = mkOption {
|
|
|
|
type = types.enum [ "center" "fill" "max" "scale" "tile" ];
|
|
|
|
default = "scale";
|
|
|
|
example = "fill";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2022-08-21 13:32:41 +00:00
|
|
|
The file {file}`~/.background-image` is used as a background image.
|
2020-04-24 23:36:52 +00:00
|
|
|
This option specifies the placement of this image onto your desktop.
|
|
|
|
|
|
|
|
Possible values:
|
2022-08-21 13:32:41 +00:00
|
|
|
`center`: Center the image on the background. If it is too small, it will be surrounded by a black border.
|
|
|
|
`fill`: Like `scale`, but preserves aspect ratio by zooming the image until it fits. Either a horizontal or a vertical part of the image will be cut off.
|
|
|
|
`max`: Like `fill`, but scale the image to the maximum size that fits the screen with black borders on one side.
|
|
|
|
`scale`: Fit the file into the background without repeating it, cutting off stuff or using borders. But the aspect ratio is not preserved either.
|
|
|
|
`tile`: Tile (repeat) the image in case it is too small for the screen.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
combineScreens = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2022-08-21 13:32:41 +00:00
|
|
|
When set to `true` the wallpaper will stretch across all screens.
|
|
|
|
When set to `false` the wallpaper is duplicated to all screens.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
session = mkOption {
|
|
|
|
internal = true;
|
|
|
|
default = [];
|
2024-05-15 15:35:15 +00:00
|
|
|
example = lib.singleton
|
2020-04-24 23:36:52 +00:00
|
|
|
{ name = "kde";
|
|
|
|
bgSupport = true;
|
|
|
|
start = "...";
|
|
|
|
};
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Internal option used to add some common line to desktop manager
|
|
|
|
scripts before forwarding the value to the
|
2022-09-09 14:08:57 +00:00
|
|
|
`displayManager`.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
apply = map (d: d // {
|
|
|
|
manage = "desktop";
|
|
|
|
start = d.start
|
2022-07-14 12:49:19 +00:00
|
|
|
# literal newline to ensure d.start's last line is not appended to
|
2024-05-15 15:35:15 +00:00
|
|
|
+ lib.optionalString (needBGCond d) ''
|
2022-07-14 12:49:19 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
if [ -e $HOME/.background-image ]; then
|
2024-05-15 15:35:15 +00:00
|
|
|
${pkgs.feh}/bin/feh --bg-${cfg.wallpaper.mode} ${lib.optionalString cfg.wallpaper.combineScreens "--no-xinerama"} $HOME/.background-image
|
2020-04-24 23:36:52 +00:00
|
|
|
fi
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config.services.xserver.displayManager.session = cfg.session;
|
|
|
|
}
|