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

let

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

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

  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
  ];
}