From 557e694c0eb48bd90fc81544b9520eaa606d6cff Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 18 Mar 2024 16:55:45 +0300 Subject: [PATCH] pkgs: init mpvScripts under applications/video --- .../video/mpv/scripts/save-history/default.nix | 16 ++++++++++++++++ .../mpv/scripts/save-history/save-history.lua | 12 ++++++++++++ pkgs/top-level.nix | 15 ++++++--------- 3 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 pkgs/applications/video/mpv/scripts/save-history/default.nix create mode 100644 pkgs/applications/video/mpv/scripts/save-history/save-history.lua diff --git a/pkgs/applications/video/mpv/scripts/save-history/default.nix b/pkgs/applications/video/mpv/scripts/save-history/default.nix new file mode 100644 index 0000000..56fe2bc --- /dev/null +++ b/pkgs/applications/video/mpv/scripts/save-history/default.nix @@ -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]; + }; +} diff --git a/pkgs/applications/video/mpv/scripts/save-history/save-history.lua b/pkgs/applications/video/mpv/scripts/save-history/save-history.lua new file mode 100644 index 0000000..0ab9842 --- /dev/null +++ b/pkgs/applications/video/mpv/scripts/save-history/save-history.lua @@ -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) diff --git a/pkgs/top-level.nix b/pkgs/top-level.nix index 08dc68d..a977e4d 100644 --- a/pkgs/top-level.nix +++ b/pkgs/top-level.nix @@ -4,21 +4,18 @@ callPackage, ... }: { - /* - packages that follow npins entries - they can be updated via npins - */ + # packages that follow npins entries + # they can be updated via npins ani-cli = mkPackage ./applications/misc/ani-cli; rat = mkPackage ./applications/misc/rat; rofi-calc-wayland = mkPackage ./applications/misc/rofi-calc-wayland; rofi-emoji-wayland = mkPackage ./applications/misc/rofi-emoji-wayland; - /* - static packages - need manual intervention with each update - */ - mov-cli = callPackage ./applications/misc/mov-cli {}; + # static packages + # need manual intervention with each update cloneit = callPackage ./applications/misc/cloneit {}; + mov-cli = callPackage ./applications/misc/mov-cli {}; + mpv-history = callPackage ./applications/video/mpv/scripts/save-history {}; mastodon-bird-ui = callPackage ./applications/social/mastodon-bird-ui {}; headscale-ui = callPackage ./applications/networking/headscale-ui {}; reposilite-bin = callPackage ./applications/networking/reposilite-bin {