mpv: auto-populate internal playlist with other files in the same directory, on launch

so now i can listen to whole albums by opening any file from within them.
and for shows the next episode will automatically launch.
This commit is contained in:
2024-03-09 03:02:09 +00:00
parent 9ea39799a5
commit 8af962c3a6

View File

@@ -3,6 +3,8 @@
# mpv docs: # mpv docs:
# - <https://mpv.io/manual/master> # - <https://mpv.io/manual/master>
# - <https://github.com/mpv-player/mpv/wiki> # - <https://github.com/mpv-player/mpv/wiki>
# extensions i use:
# - <https://github.com/jonniek/mpv-playlistmanager>
# debugging: # debugging:
# - enter console by pressing backtick. # - enter console by pressing backtick.
# > `set volume 50` -> sets application volume to 50% # > `set volume 50` -> sets application volume to 50%
@@ -12,6 +14,10 @@
# - and then just `print(...)` from lua & it'll show in terminal # - and then just `print(...)` from lua & it'll show in terminal
# - invoke mpv with `--no-config` to have it not read ~/.config/mpv/* # - invoke mpv with `--no-config` to have it not read ~/.config/mpv/*
# - press `i` to show decoder info # - press `i` to show decoder info
#
# usage tips:
# - `<` or `>` to navigate prev/next-file-in-folder (uosc)
# - shift+enter to view the playlist, then arrow-keys to navigate (mpv-playlistmanager)
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
let let
@@ -31,7 +37,8 @@ let
# `ao-volume` isn't actually an observable property. # `ao-volume` isn't actually an observable property.
# as of 2024/03/02, they *may* be working on that: # as of 2024/03/02, they *may* be working on that:
# - <https://github.com/mpv-player/mpv/pull/13604#issuecomment-1971665736> # - <https://github.com/mpv-player/mpv/pull/13604#issuecomment-1971665736>
# in the meantime, just query the volume every tick (i.e. frame) # in the meantime, just query the volume every tick (i.e. frame).
# alternative is mpv's JSON IPC feature, where i could notify its socket whenever pipewire volume changes.
cat <<EOF >> src/uosc/main.lua cat <<EOF >> src/uosc/main.lua
function update_ao_volume() function update_ao_volume()
local vol = mp.get_property('ao-volume') local vol = mp.get_property('ao-volume')
@@ -62,6 +69,7 @@ in
packageUnwrapped = with pkgs; wrapMpv mpv-unwrapped { packageUnwrapped = with pkgs; wrapMpv mpv-unwrapped {
scripts = [ scripts = [
mpvScripts.mpris mpvScripts.mpris
mpvScripts.mpv-playlistmanager
uosc uosc
# pkgs.mpv-uosc-latest # pkgs.mpv-uosc-latest
]; ];
@@ -162,8 +170,15 @@ in
# TODO: unify "Cast" and "Cast (stream)" options above. # TODO: unify "Cast" and "Cast (stream)" options above.
''; '';
fs.".config/mpv/mpv.conf".symlink.text = '' fs.".config/mpv/mpv.conf".symlink.text = ''
# write ~/.local/state/mpv/watch_later on exit, to allow resume
save-position-on-quit=yes save-position-on-quit=yes
# identify resumed files by filename only, since i use so many symlinks and doubt mpv does well with that.
ignore-path-in-watch-later-config
# keep-open: don't exit on completion of last file in playlist
keep-open=yes keep-open=yes
# seeking once at the end of the file causes auto-resume
keep-open-pause=no
# force GUI, even for tracks w/o album art # force GUI, even for tracks w/o album art
# see: <https://www.reddit.com/r/mpv/comments/rvrrpt/oscosdgui_and_arch_linux/> # see: <https://www.reddit.com/r/mpv/comments/rvrrpt/oscosdgui_and_arch_linux/>
@@ -189,6 +204,11 @@ in
# if uosc is installed, this file is unused # if uosc is installed, this file is unused
visibility=always visibility=always
''; '';
fs.".config/mpv/script-opts/console.conf".symlink.text = ''
# font size used by mpv's console (`); default 16
# font_size=28
scale=2
'';
fs.".config/mpv/script-opts/uosc.conf".symlink.text = let fs.".config/mpv/script-opts/uosc.conf".symlink.text = let
play_pause_btn = "cycle:play_arrow:pause:no=pause/yes=play_arrow"; play_pause_btn = "cycle:play_arrow:pause:no=pause/yes=play_arrow";
rev_btn = "command:replay_10:seek -10"; rev_btn = "command:replay_10:seek -10";
@@ -217,6 +237,12 @@ in
ui_scale=1.0 ui_scale=1.0
''; '';
fs.".config/mpv/script-opts/playlistmanager.conf".symlink.text = ''
# script docs: <https://github.com/jonniek/mpv-playlistmanager>
# auto-populate playlist with other files in the same directory, on launch.
loadfiles_on_start=yes
'';
# mime.priority = 200; # default = 100; 200 means to yield to other apps # mime.priority = 200; # default = 100; 200 means to yield to other apps
mime.priority = 50; # default = 100; 50 in order to take precedence over vlc. mime.priority = 50; # default = 100; 50 in order to take precedence over vlc.