summaryrefslogtreecommitdiffstats
path: root/lass/2configs/mpv.nix
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2016-05-24 22:27:21 +0200
committermakefu <github@syntax-fehler.de>2016-05-24 22:27:21 +0200
commitc1971f5aa04553c022fac4d7df7221aef66826a2 (patch)
treeb13db787aea2c4380b1308112d542eb1b7a4bc9d /lass/2configs/mpv.nix
parent9cba0ffefa95079168f3419cf11eb98400a468db (diff)
parentfacb65bd22226742b1805138b2841b29c4c26012 (diff)
Merge remote-tracking branch 'cloudkrebs/master'
Diffstat (limited to 'lass/2configs/mpv.nix')
-rw-r--r--lass/2configs/mpv.nix49
1 files changed, 49 insertions, 0 deletions
diff --git a/lass/2configs/mpv.nix b/lass/2configs/mpv.nix
new file mode 100644
index 000000000..ff5698e4e
--- /dev/null
+++ b/lass/2configs/mpv.nix
@@ -0,0 +1,49 @@
+{ pkgs, lib, ... }:
+
+let
+
+ mpv-config = pkgs.writeText "mpv-config" ''
+ script=${lib.concatStringsSep "," [
+ good
+ delete
+ ]}
+ '';
+ mpv = pkgs.writeDashBin "mpv" ''
+ exec ${pkgs.mpv}/bin/mpv --no-config --include=${mpv-config} "$@"
+ '';
+
+ 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.
+ 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
+ ];
+}