Configure mpv
This commit is contained in:
parent
264757b51c
commit
2d61efec23
|
@ -1,5 +1,6 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
{
|
||||
imports = [ ./mpv ];
|
||||
home.packages = builtins.attrValues rec {
|
||||
zoom = pkgs.zoom-us.overrideAttrs (old: {
|
||||
postFixup = old.postFixup + ''
|
||||
|
@ -25,7 +26,6 @@
|
|||
abcde beets zbar
|
||||
|
||||
# media
|
||||
ncpamixer pavucontrol deluge gmpc vlc mpv youtubeDL syncplay;
|
||||
|
||||
ncpamixer pavucontrol deluge gmpc vlc youtubeDL syncplay;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@ in
|
|||
Minecraft = fork "minecraft-launcher";
|
||||
};
|
||||
Deluge = fork "deluge";
|
||||
VoxMachina = fork "mpv https://www.youtube.com/playlist?list=PL1tiwbzkOjQz7D0l_eLJGAISVtcL7oRu_";
|
||||
};
|
||||
}
|
||||
{ Files = fork "nautilus"; }
|
||||
|
|
55
home-manager/roles/mpv/autosave.lua
Normal file
55
home-manager/roles/mpv/autosave.lua
Normal file
|
@ -0,0 +1,55 @@
|
|||
-- autosave.lua
|
||||
--
|
||||
-- Periodically saves "watch later" data during playback, rather than only saving on quit.
|
||||
-- This lets you easily recover your position in the case of an ungraceful shutdown of mpv (crash, power failure, etc.).
|
||||
--
|
||||
-- You can configure the save period by creating a "lua-settings" directory inside your mpv configuration directory.
|
||||
-- Inside the "lua-settings" directory, create a file named "autosave.conf".
|
||||
-- The save period can be set like so:
|
||||
--
|
||||
-- save_period=60
|
||||
--
|
||||
-- This will set the save period to once every 60 seconds of playback, time while paused is not counted towards the save period timer.
|
||||
-- The default save period is 30 seconds.
|
||||
local options = require 'mp.options'
|
||||
|
||||
local o = {
|
||||
save_period = 30
|
||||
}
|
||||
|
||||
options.read_options(o)
|
||||
|
||||
local mp = require 'mp'
|
||||
|
||||
local function save()
|
||||
mp.commandv("set", "msg-level", "cplayer=warn")
|
||||
mp.command("write-watch-later-config")
|
||||
mp.commandv("set", "msg-level", "cplayer=status")
|
||||
end
|
||||
|
||||
local save_period_timer = mp.add_periodic_timer(o.save_period, save)
|
||||
|
||||
local function pause(name, paused)
|
||||
save()
|
||||
if paused then
|
||||
save_period_timer:stop()
|
||||
else
|
||||
save_period_timer:resume()
|
||||
end
|
||||
end
|
||||
|
||||
mp.observe_property("pause", "bool", pause)
|
||||
mp.register_event("file-loaded", save)
|
||||
|
||||
local function end_file(data)
|
||||
if data.reason == 'eof' or data.reason == 'stop' then
|
||||
local playlist = mp.get_property_native('playlist')
|
||||
for i, entry in pairs(playlist) do
|
||||
if entry.id == data.playlist_entry_id then
|
||||
mp.commandv("delete-watch-later-config", entry.filename)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
mp.register_event("end-file", end_file)
|
20
home-manager/roles/mpv/default.nix
Normal file
20
home-manager/roles/mpv/default.nix
Normal file
|
@ -0,0 +1,20 @@
|
|||
{ pkgs, ... }:
|
||||
let script = pkgs.runCommand "autosave.lua" { passthru.scriptName = "autosave.lua"; } ''
|
||||
mkdir -p $out/share/mpv/scripts/
|
||||
ln -s ${./autosave.lua} $out/share/mpv/scripts/autosave.lua
|
||||
'';
|
||||
in
|
||||
{
|
||||
programs.mpv = {
|
||||
enable = true;
|
||||
config = {
|
||||
save-position-on-quit = true;
|
||||
osc = false;
|
||||
};
|
||||
scripts = [
|
||||
pkgs.mpvScripts.mpris
|
||||
pkgs.mpvScripts.thumbnail
|
||||
script
|
||||
];
|
||||
};
|
||||
}
|
|
@ -14,6 +14,7 @@ let
|
|||
".config/gh"
|
||||
".contacts"
|
||||
".gnupg"
|
||||
".config/mpv/watch_later"
|
||||
".local/share/Mumble"
|
||||
".local/share/TelegramDesktop"
|
||||
".local/share/direnv"
|
||||
|
|
Loading…
Reference in a new issue