about summary refs log tree commit diff
path: root/desktop.nix
blob: 5f9746bf7c79f937fb76f1580b647c2e79edd0a5 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Configuration for the desktop environment

{ config, lib, pkgs, ... }:

let emacs = import ./emacs.nix { inherit pkgs; };
screenLock = pkgs.writeShellScriptBin "screen-lock" ''
  find ${pkgs.wallpapers} -name "*.png" | shuf -n1 | xargs i3lock -f -t -i
'';
in {
  # Configure basic X-server stuff:
  services.xserver = {
    enable = true;
    layout = "us,no,ru";
    xkbOptions = "caps:super, grp:shifts_toggle, parens:swap_brackets";
    exportConfiguration = true;

    # Give EXWM permission to control the session.
    displayManager.sessionCommands = "${pkgs.xorg.xhost}/bin/xhost +SI:localuser:$USER";
  };

  # Add a shell script with random screen lock wallpaper selection
  environment.systemPackages = [ screenLock ];

  # Apparently when you have house guests they complain about your screen tearing!
  services.compton.enable = true;
  services.compton.backend = "xrender";

  # Configure desktop environment:
  services.xserver.windowManager.session = lib.singleton {
    name = "exwm";
    start = ''
      ${emacs}/bin/emacs --daemon -f exwm-enable
      ${emacs}/bin/emacsclient -c
    '';
  };

  # Configure Redshift for Oslo
  services.redshift = {
    enable = true;
    latitude = "59.911491";
    longitude = "10.757933";
  };

  # Configure fonts
  fonts = {
    fonts = with pkgs; [
      corefonts
      font-awesome-ttf
      input-fonts
      noto-fonts-cjk
      noto-fonts-emoji
      powerline-fonts
      helvetica-neue-lt-std
    ];
  };

  # Configure random setting of wallpapers
  systemd.user.services.feh-wp = {
    description = "Randomly set wallpaper via feh";
    serviceConfig = {
      Type             = "oneshot";
      WorkingDirectory = "${pkgs.wallpapers}/share/wallpapers";

      # Manually shuffle because feh's --randomize option can't be restricted to
      # just certain file types.
      ExecStart = "${pkgs.bash}/bin/bash -c '${pkgs.fd}/bin/fd -atf | shuf | head -n1 | ${pkgs.findutils}/bin/xargs ${pkgs.feh}/bin/feh --bg-fill'";
    };
  };

  systemd.user.timers.feh-wp = {
    description = "Set a random wallpaper every hour";
    wantedBy    = [ "graphical-session.target" ];
    partOf      = [ "graphical-session.target" ];

    timerConfig = {
      OnActiveSec     = "1second";
      OnUnitActiveSec = "1hour";
    };
  };
}