summaryrefslogtreecommitdiffstats
path: root/lass/2configs/mpv.nix
blob: 04fd9213e1d2ba8a773880f2e81c8b6fd79a6ede (plain)
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
{ pkgs, lib, ... }:

let

  scripts = lib.concatStringsSep "," [
    good
    delete
  ];

  mpv = pkgs.symlinkJoin {
    name = "mpv";
    paths = [
      (pkgs.writeDashBin "mpv" ''
        exec ${pkgs.mpv}/bin/mpv --no-config --script=${scripts} "$@"
      '')
      pkgs.mpv
    ];
  };

  moveToDir = key: dir: pkgs.writeText "move-with-${key}.lua" ''
    tmp_dir = "${dir}"

    function move_current_track_${key}()
      track = mp.get_property("path")
      os.execute("mkdir -p '" .. tmp_dir .. "'")
      os.execute("mv '" .. track .. "' '" .. tmp_dir .. "'")
      print("moved '" .. track .. "' to " .. tmp_dir)
    end

    mp.add_key_binding("${key}", "move_current_track_${key}", move_current_track_${key})
  '';

  good = moveToDir "G" "./.good";
  delete = moveToDir "D" "./.graveyard";

  up = moveToDir "U" "./up";
  down = moveToDir "Y" "./down";

in {
  environment.systemPackages = [
    mpv
  ];
}