pkgs: init mpvScripts under applications/video

This commit is contained in:
raf 2024-03-18 16:55:45 +03:00
commit 557e694c0e
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
3 changed files with 34 additions and 9 deletions

View file

@ -0,0 +1,16 @@
{
lib,
mpvScripts,
}:
mpvScripts.buildLua {
pname = "save-history";
version = "unstable-2024-03-18";
src = builtins.filterSource (path: type: type != "directory" || (!lib.hasSuffix path ".nix")) ./.;
meta = {
description = "Save history of played files";
homepage = "https://github.com/notashelf/nyxpkgs";
maintainers = [lib.maintainers.NotAShelf];
};
}

View file

@ -0,0 +1,12 @@
local HISTFILE = (os.getenv('XDG_DATA_HOME') or os.getenv('HOME')) .. '/mpv/history.log';
mp.register_event('file-loaded', function()
local title, fp;
title = mp.get_property('media-title');
title = (title == mp.get_property('filename') and "" or (' (%s)'):format(title));
fp = io.open(HISTFILE, 'a+');
fp:write(('[%s] %s%s\n'):format(os.date('%Y-%m-%d %X'), mp.get_property('path'), title));
fp:close();
end)