stockholm/lass/2configs/mpv.nix

53 lines
1.3 KiB
Nix
Raw Normal View History

{ pkgs, lib, ... }:
2016-04-28 20:55:18 +00:00
let
mpv-config = pkgs.writeText "mpv-config" ''
script=${lib.concatStringsSep "," [
good
delete
]}
2016-04-28 20:55:18 +00:00
'';
mpv = pkgs.writeDashBin "mpv" ''
exec ${pkgs.mpv}/bin/mpv --no-config --include=${mpv-config} "$@"
2016-04-28 20:55:18 +00:00
'';
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";
2016-08-06 21:16:18 +00:00
up = moveToDir "U" "./up";
down = moveToDir "Y" "./down";
deleteCurrentTrack = pkgs.writeText "delete.lua" ''
2016-04-28 20:55:18 +00:00
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
];
}