2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2010-08-08 16:05:32 +02:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2009-01-25 16:49:08 +01:00
|
|
|
|
|
|
|
let
|
2010-08-08 16:05:32 +02:00
|
|
|
|
2009-06-26 00:08:03 +02:00
|
|
|
xcfg = config.services.xserver;
|
|
|
|
cfg = xcfg.desktopManager;
|
2009-01-25 16:49:08 +01:00
|
|
|
|
2014-03-04 09:10:23 +01:00
|
|
|
# If desktop manager `d' isn't capable of setting a background and
|
2017-04-16 18:59:44 +02:00
|
|
|
# the xserver is enabled, `feh' or `xsetroot' are used as a fallback.
|
2014-03-04 09:10:23 +01:00
|
|
|
needBGCond = d: ! (d ? bgSupport && d.bgSupport) && xcfg.enable;
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-01-25 16:49:08 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
2010-08-08 16:05:32 +02:00
|
|
|
# Note: the order in which desktop manager modules are imported here
|
|
|
|
# determines the default: later modules (if enabled) are preferred.
|
2017-02-25 21:43:13 +01:00
|
|
|
# E.g., if Plasma 5 is enabled, it supersedes xterm.
|
2014-07-21 12:05:57 +02:00
|
|
|
imports = [
|
2017-02-25 21:43:13 +01:00
|
|
|
./none.nix ./xterm.nix ./xfce.nix ./plasma5.nix ./lumina.nix
|
2017-07-04 12:42:53 +02:00
|
|
|
./lxqt.nix ./enlightenment.nix ./gnome3.nix ./kodi.nix ./maxx.nix
|
2014-07-21 12:05:57 +02:00
|
|
|
];
|
2009-01-25 16:49:08 +01:00
|
|
|
|
2009-09-15 10:33:45 +02:00
|
|
|
options = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-09-15 10:33:45 +02:00
|
|
|
services.xserver.desktopManager = {
|
2009-01-25 16:49:08 +01:00
|
|
|
|
2017-05-03 22:56:39 +02:00
|
|
|
wallpaper = {
|
|
|
|
mode = mkOption {
|
|
|
|
type = types.enum [ "center" "fill" "max" "scale" "tile" ];
|
|
|
|
default = "scale";
|
|
|
|
example = "fill";
|
|
|
|
description = ''
|
2017-05-05 21:21:32 +02:00
|
|
|
The file <filename>~/.background-image</filename> is used as a background image.
|
|
|
|
This option specifies the placement of this image onto your desktop.
|
|
|
|
|
|
|
|
Possible values:
|
2017-05-03 22:56:39 +02:00
|
|
|
<literal>center</literal>: Center the image on the background. If it is too small, it will be surrounded by a black border.
|
|
|
|
<literal>fill</literal>: Like <literal>scale</literal>, 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.
|
|
|
|
<literal>max</literal>: Like <literal>fill</literal>, but scale the image to the maximum size that fits the screen with black borders on one side.
|
|
|
|
<literal>scale</literal>: Fit the file into the background without repeating it, cutting off stuff or using borders. But the aspect ratio is not preserved either.
|
|
|
|
<literal>tile</literal>: Tile (repeat) the image in case it is too small for the screen.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
combineScreens = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
When set to <literal>true</literal> the wallpaper will stretch across all screens.
|
|
|
|
When set to <literal>false</literal> the wallpaper is duplicated to all screens.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2009-09-15 10:33:45 +02:00
|
|
|
session = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
internal = true;
|
2009-09-15 10:33:45 +02:00
|
|
|
default = [];
|
2010-08-08 16:05:32 +02:00
|
|
|
example = singleton
|
|
|
|
{ name = "kde";
|
|
|
|
bgSupport = true;
|
|
|
|
start = "...";
|
|
|
|
};
|
2013-10-30 17:37:45 +01:00
|
|
|
description = ''
|
2009-09-15 10:33:45 +02:00
|
|
|
Internal option used to add some common line to desktop manager
|
|
|
|
scripts before forwarding the value to the
|
|
|
|
<varname>displayManager</varname>.
|
2013-10-30 17:37:45 +01:00
|
|
|
'';
|
2009-09-15 10:33:45 +02:00
|
|
|
apply = list: {
|
|
|
|
list = map (d: d // {
|
|
|
|
manage = "desktop";
|
|
|
|
start = d.start
|
|
|
|
+ optionalString (needBGCond d) ''
|
2017-04-16 18:59:44 +02:00
|
|
|
if [ -e $HOME/.background-image ]; then
|
2017-05-03 22:56:39 +02:00
|
|
|
${pkgs.feh}/bin/feh --bg-${cfg.wallpaper.mode} ${optionalString cfg.wallpaper.combineScreens "--no-xinerama"} $HOME/.background-image
|
2017-04-16 18:59:44 +02:00
|
|
|
else
|
|
|
|
# Use a solid black background as fallback
|
|
|
|
${pkgs.xorg.xsetroot}/bin/xsetroot -solid black
|
2009-09-15 10:33:45 +02:00
|
|
|
fi
|
|
|
|
'';
|
|
|
|
}) list;
|
|
|
|
needBGPackages = [] != filter needBGCond list;
|
2009-01-25 16:49:08 +01:00
|
|
|
};
|
2009-09-15 10:33:45 +02:00
|
|
|
};
|
2009-01-25 16:49:08 +01:00
|
|
|
|
2009-09-15 10:33:45 +02:00
|
|
|
default = mkOption {
|
2013-10-30 11:02:04 +01:00
|
|
|
type = types.str;
|
2010-08-08 16:05:32 +02:00
|
|
|
default = "";
|
2009-09-15 10:33:45 +02:00
|
|
|
example = "none";
|
2010-08-08 16:05:32 +02:00
|
|
|
description = "Default desktop manager loaded if none have been chosen.";
|
2009-09-15 10:33:45 +02:00
|
|
|
apply = defaultDM:
|
2010-08-08 16:05:32 +02:00
|
|
|
if defaultDM == "" && cfg.session.list != [] then
|
|
|
|
(head cfg.session.list).name
|
|
|
|
else if any (w: w.name == defaultDM) cfg.session.list then
|
2009-09-15 10:33:45 +02:00
|
|
|
defaultDM
|
|
|
|
else
|
2016-01-31 21:57:47 +01:00
|
|
|
throw ''
|
|
|
|
Default desktop manager (${defaultDM}) not found.
|
|
|
|
Probably you want to change
|
|
|
|
services.xserver.desktopManager.default = "${defaultDM}";
|
|
|
|
to one of
|
|
|
|
${concatMapStringsSep "\n " (w: "services.xserver.desktopManager.default = \"${w.name}\";") cfg.session.list}
|
|
|
|
'';
|
2009-01-25 16:49:08 +01:00
|
|
|
};
|
2009-09-15 10:33:45 +02:00
|
|
|
|
2009-01-25 16:49:08 +01:00
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-01-25 16:49:08 +01:00
|
|
|
};
|
|
|
|
|
2009-09-15 10:33:45 +02:00
|
|
|
config = {
|
|
|
|
services.xserver.displayManager.session = cfg.session.list;
|
2013-10-30 17:52:35 +01:00
|
|
|
environment.systemPackages =
|
2017-04-16 18:59:44 +02:00
|
|
|
mkIf cfg.session.needBGPackages [ pkgs.feh ]; # xsetroot via xserver.enable
|
2009-01-25 16:49:08 +01:00
|
|
|
};
|
|
|
|
}
|