about summary refs log tree commit diff
path: root/wallpapers.nix
blob: 4faf7ef52c51bc707970ab2b7199c111067eadde (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
# Configuration for randomly setting wallpapers.
{ config, pkgs, ... }:

{
  # Configure random setting of wallpapers
  systemd.user.services.clone-wallpapers = {
    description = "Clone wallpaper repository";
    enable = true;
    before = [ "feh-wp.service" "feh-wp.timer" ];
    serviceConfig = {
      Type = "oneshot";
      ExecStart = "${pkgs.fish}/bin/fish -c '${pkgs.coreutils}/bin/stat %h/wallpapers; or ${pkgs.git}/bin/git clone https://git.tazj.in/tazjin/wallpapers.git %h/wallpapers'";
    };
  };

  systemd.user.services.feh-wp = {
    description = "Randomly set wallpaper via feh";
    serviceConfig = {
      Type = "oneshot";
      WorkingDirectory = "%h/wallpapers";
      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 = [ "timers.target" ];

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