l 2 mpv: refactor, add "mark as good" key
This commit is contained in:
parent
22627e6ce7
commit
4d5dadc8e5
@ -1,15 +1,34 @@
|
|||||||
{ pkgs, ... }:
|
{ pkgs, lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
mpv-config = pkgs.writeText "mpv-config" ''
|
mpv-config = pkgs.writeText "mpv-config" ''
|
||||||
script=${deleteCurrentFile}
|
script=${lib.concatStringsSep "," [
|
||||||
|
good
|
||||||
|
delete
|
||||||
|
]}
|
||||||
'';
|
'';
|
||||||
mpv = pkgs.writeDashBin "mpv" ''
|
mpv = pkgs.writeDashBin "mpv" ''
|
||||||
exec ${pkgs.mpv}/bin/mpv --no-config --include=${mpv-config} $@
|
exec ${pkgs.mpv}/bin/mpv --no-config --include=${mpv-config} "$@"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
deleteCurrentFile = pkgs.writeText "delete.lua" ''
|
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";
|
||||||
|
|
||||||
|
deleteCurrentTrack = pkgs.writeText "delete.lua" ''
|
||||||
deleted_tmp = "./.graveyard"
|
deleted_tmp = "./.graveyard"
|
||||||
|
|
||||||
-- Delete the current track by moving it to the `deleted_tmp` location.
|
-- Delete the current track by moving it to the `deleted_tmp` location.
|
||||||
|
Loading…
Reference in New Issue
Block a user