about summary refs log tree commit diff
path: root/modules/user/aszlig/services/slim/default.nix
blob: 6e61912ae9e1be538d1f9b9b7ee7467f81572280 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{ pkgs, config, lib, ... }:

with lib;

let
  cfg = config.vuizvui.user.aszlig.services.slim;
  randrHeads = config.services.xserver.xrandrHeads;
in {
  options.vuizvui.user.aszlig.services.slim = {
    enable = mkEnableOption "Vuizvui SLiM";
  };

  config.services.xserver.displayManager.slim = mkIf cfg.enable {
    enable = true;
    theme = pkgs.stdenv.mkDerivation {
      name = "nixos-theme-vuizvui";
      src = pkgs.slimThemes.nixosSlim;
      phases = [ "unpackPhase" "patchPhase" "installPhase" ];
      patchPhase = let
        headFactor = if randrHeads == [] then 1 else lib.length randrHeads;
        centerLeft = 100 / (headFactor * 2);
      in ''
        "${pkgs.imagemagick.out}/bin/mogrify" \
          -fill '#080010' -draw 'color 0,0 reset' \
          share/slim/themes/nixos-slim-testing/background.png
        "${pkgs.imagemagick.out}/bin/mogrify" \
          -negate -region 100x110+0+0 -negate -fill white -colorize 20% \
          share/slim/themes/nixos-slim-testing/panel.png
        sed -i \
          -e 's/^\([a-z_]\+_x[^0-9]*\)[0-9]\+%/\1${toString centerLeft}%/' \
          share/slim/themes/nixos-slim-testing/slim.theme
        cat >> share/slim/themes/nixos-slim-testing/slim.theme <<EOF
        session_x      ${toString centerLeft}%
        msg_color      #ffffff
        username_color #ffffff
        password_color #ffffff
        input_color    #ffffff
        EOF
      '';
      installPhase = ''
        cp -R share/slim/themes/nixos-slim-testing "$out"
      '';
    };
  };
}