summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlassulus <lass@aidsballs.de>2016-05-04 17:21:09 +0200
committerlassulus <lass@aidsballs.de>2016-05-04 17:21:09 +0200
commit4d5dadc8e53f8060e13605c5a93658052d8c2378 (patch)
tree6743836c3e26554ee66a7d26eda042846bcc2e42
parent22627e6ce73a03fcb909da532bc0ce982d350ad2 (diff)
l 2 mpv: refactor, add "mark as good" key
-rw-r--r--lass/2configs/mpv.nix27
1 files changed, 23 insertions, 4 deletions
diff --git a/lass/2configs/mpv.nix b/lass/2configs/mpv.nix
index 71f1409e0..ff5698e4e 100644
--- a/lass/2configs/mpv.nix
+++ b/lass/2configs/mpv.nix
@@ -1,15 +1,34 @@
-{ pkgs, ... }:
+{ pkgs, lib, ... }:
let
mpv-config = pkgs.writeText "mpv-config" ''
- script=${deleteCurrentFile}
+ script=${lib.concatStringsSep "," [
+ good
+ delete
+ ]}
'';
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"
-- Delete the current track by moving it to the `deleted_tmp` location.