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

let

  mpv-config = pkgs.writeText "mpv-config" ''
    script=${deleteCurrentFile}
  '';
  mpv = pkgs.writeDashBin "mpv" ''
    exec ${pkgs.mpv}/bin/mpv --no-config --include=${mpv-config} $@
  '';

  deleteCurrentFile = pkgs.writeText "delete.lua" ''
    deleted_tmp = "./.graveyard"

    -- Delete the current track by moving it to the `deleted_tmp` location.
    function delete_current_track()
      track = mp.get_property("path")
      os.execute("mkdir -p '" .. deleted_tmp .. "'")
      os.execute("mv '" .. track .. "' '" .. deleted_tmp .. "'")
      print("'" .. track .. "' deleted.")
    end

    mp.add_key_binding("D", "delete_current_track", delete_current_track)
  '';

in {
  krebs.per-user.lass.packages = [
    mpv
  ];
}