Home

infra @826aacb6ae80b1219319695623c36b5445a276e8 - refs - log -
-
https://git.jolheiser.com/infra.git
dragonwell flake
infra / jasmine / slideshow.nix
- raw -
 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
{ pkgs, ... }:
let
  root = "/mnt/feh";
  slideshow = pkgs.writeShellApplication {
    name = "slideshow";
    runtimeInputs = with pkgs; [
      coreutils
      findutils
      mpv
    ];
    text = ''
      while true; do
        month=$(date +%B | tr '[:upper:]' '[:lower:]')
        
        playlist="/tmp/slideshow.txt"
        touch "$playlist"
        
        find ${root} -maxdepth 1 -type f >> "$playlist"
        
        if [ -d "${root}/$month" ]; then
          find "${root}/$month" -type f >> "$playlist"
        fi
        
        mpv --shuffle --image-display-duration=5 --fullscreen --playlist="$playlist"
      done
    '';
  };
in
{
  systemd.user.services = {
    slideshow = {
      description = "Autostart slideshow";
      wantedBy = [ "graphical-session.target" ];
      after = [ "graphical-session.target" ];
      serviceConfig = {
        ExecStart = pkgs.lib.getExe slideshow;
        Restart = "always";
        PrivateTmp = true;
      };
    };
    disable-dpms = {
      description = "Disable screen blanking";
      wantedBy = [ "graphical-session.target" ];
      after = [ "graphical-session.target" ];
      serviceConfig = {
        Type = "oneshot";
        ExecStart = "${pkgs.lib.getExe pkgs.xorg.xset} s off -dpms";
      };
    };
  };
}