diff --git a/hosts/common/programs/mpv/default.nix b/hosts/common/programs/mpv/default.nix index d4730f8e6..bbb61f506 100644 --- a/hosts/common/programs/mpv/default.nix +++ b/hosts/common/programs/mpv/default.nix @@ -137,43 +137,50 @@ let in { sane.programs.mpv = { - packageUnwrapped = pkgs.wrapMpv (mpv-unwrapped.override { lua = pkgs.luajit; }) { - scripts = [ - pkgs.mpvScripts.mpris - pkgs.mpvScripts.mpv-playlistmanager - uosc - # pkgs.mpv-uosc-latest - ]; - # extraMakeWrapperArgs = lib.optionals (cfg.config.vo != null) [ - # # 2023/08/29: fixes an error where mpv on moby launches with the message - # # "DRM_IOCTL_MODE_CREATE_DUMB failed: Cannot allocate memory" - # # audio still works, and controls, screenshotting, etc -- just not the actual rendering - # # - # # this is likely a regression for mpv 0.36.0. - # # the actual error message *appears* to come from the mesa library, but it's tough to trace. - # # - # # 2024/03/02: no longer necessary, with mesa 23.3.1: - # # - # # backend compatibility (2023/10/22): - # # run with `--vo=help` to see a list of all output options. - # # non-exhaustive (W=works, F=fails, A=audio-only, U=audio+ui only (no video)) - # # ? null Null video output - # # A (default) - # # A dmabuf-wayland Wayland dmabuf video output - # # A libmpv render API for libmpv (mpv plays the audio, but doesn't even render a window) - # # A vdpau VDPAU with X11 - # # F drm Direct Rendering Manager (software scaling) - # # F gpu-next Video output based on libplacebo - # # F vaapi VA API with X11 - # # F x11 X11 (software scaling) - # # F xv X11/Xv - # # U gpu Shader-based GPU Renderer - # # W caca libcaca (terminal rendering) - # # W sdl SDL 2.0 Renderer - # # W wlshm Wayland SHM video output (software scaling) - # "--add-flags" "--vo=${cfg.config.vo}" - # ]; - }; + packageUnwrapped = pkgs.wrapMpv + (mpv-unwrapped.override rec { + # N.B.: populating `self` to `luajit` is necessary for the resulting `lua.withPackages` function to preserve my override. + # i use enable52Compat in order to get `table.unpack`. + # i think using `luajit` here instead of `lua` is optional, just i get better perf with it :) + lua = pkgs.luajit.override { enable52Compat = true; self = lua; }; + }) + { + scripts = [ + pkgs.mpvScripts.mpris + pkgs.mpvScripts.mpv-playlistmanager + uosc + # pkgs.mpv-uosc-latest + ]; + # extraMakeWrapperArgs = lib.optionals (cfg.config.vo != null) [ + # # 2023/08/29: fixes an error where mpv on moby launches with the message + # # "DRM_IOCTL_MODE_CREATE_DUMB failed: Cannot allocate memory" + # # audio still works, and controls, screenshotting, etc -- just not the actual rendering + # # + # # this is likely a regression for mpv 0.36.0. + # # the actual error message *appears* to come from the mesa library, but it's tough to trace. + # # + # # 2024/03/02: no longer necessary, with mesa 23.3.1: + # # + # # backend compatibility (2023/10/22): + # # run with `--vo=help` to see a list of all output options. + # # non-exhaustive (W=works, F=fails, A=audio-only, U=audio+ui only (no video)) + # # ? null Null video output + # # A (default) + # # A dmabuf-wayland Wayland dmabuf video output + # # A libmpv render API for libmpv (mpv plays the audio, but doesn't even render a window) + # # A vdpau VDPAU with X11 + # # F drm Direct Rendering Manager (software scaling) + # # F gpu-next Video output based on libplacebo + # # F vaapi VA API with X11 + # # F x11 X11 (software scaling) + # # F xv X11/Xv + # # U gpu Shader-based GPU Renderer + # # W caca libcaca (terminal rendering) + # # W sdl SDL 2.0 Renderer + # # W wlshm Wayland SHM video output (software scaling) + # "--add-flags" "--vo=${cfg.config.vo}" + # ]; + }; suggestedPrograms = [ "blast-to-default" @@ -205,7 +212,7 @@ in # for `watch_later` ".local/state/mpv" ]; - fs.".config/mpv/scripts/sane-cast/main.lua".symlink.target = ./sane-cast-main.lua; + fs.".config/mpv/scripts/sane-cast/main.lua".symlink.target = ./sane-cast/main.lua; fs.".config/mpv/scripts/sane-sysvol/main.lua".symlink.target = ./sane-sysvol/main.lua; fs.".config/mpv/scripts/sane-sysvol/non_blocking_popen.lua".symlink.target = ./sane-sysvol/non_blocking_popen.lua; fs.".config/mpv/input.conf".symlink.target = ./input.conf; diff --git a/hosts/common/programs/mpv/input.conf b/hosts/common/programs/mpv/input.conf index 28362fcac..1dd6baa14 100644 --- a/hosts/common/programs/mpv/input.conf +++ b/hosts/common/programs/mpv/input.conf @@ -33,7 +33,7 @@ ctrl+s async screenshot #! Utils > Screenshot alt+i script-binding uosc/keybinds #! Utils > Key bindings O script-binding uosc/show-in-directory #! Utils > Show in directory # script-binding uosc/open-config-directory #! Utils > Open config directory -ctrl+r script-binding sane-cast/blast #! Audiocast -ctrl+t script-binding sane-cast/go2tv-video #! Cast -# script-binding sane-cast/go2tv-stream #! Cast (...) > Stream -# script-binding sane-cast/go2tv-gui #! Cast (...) > GUI +ctrl+r script-binding sane_cast/blast #! Audiocast +ctrl+t script-binding sane_cast/go2tv-video #! Cast +# script-binding sane_cast/go2tv-stream #! Cast (...) > Stream +# script-binding sane_cast/go2tv-gui #! Cast (...) > GUI diff --git a/hosts/common/programs/mpv/sane-cast-main.lua b/hosts/common/programs/mpv/sane-cast/main.lua similarity index 59% rename from hosts/common/programs/mpv/sane-cast-main.lua rename to hosts/common/programs/mpv/sane-cast/main.lua index 2075c46ea..0bdf672bb 100644 --- a/hosts/common/programs/mpv/sane-cast-main.lua +++ b/hosts/common/programs/mpv/sane-cast/main.lua @@ -1,7 +1,11 @@ +msg = require("mp.msg") +msg.trace("load: begin") + function subprocess(in_terminal, args) if in_terminal then args = { "xdg-terminal-exec", table.unpack(args) } end + msg.info(table.concat(args, " ")) mp.command_native({ name = "subprocess", args = args, @@ -20,15 +24,15 @@ function invoke_go2tv(in_terminal, args) end function invoke_go2tv_on_open_file(mode) - local path = mp.get_property("stream-open-filename"); - return invoke_go2tv(true, { mode, path }) + msg.trace("invoke_go2tv_on_open_file") + local path = mp.get_property("stream-open-filename") + msg.trace("path:", path) + invoke_go2tv(true, { mode, path }) end mp.add_key_binding(nil, "blast", function() subprocess(false, { "blast-to-default" }) end) -mp.add_key_binding(nil, 'go2tv-gui', function() invoke_go2tv(false, {}) end) -mp.add_key_binding(nil, 'go2tv-video', function() invoke_go2tv_on_open_file("-v") end) -mp.add_key_binding(nil, 'go2tv-stream', function() invoke_go2tv_on_open_file("-s") end) +mp.add_key_binding(nil, "go2tv-gui", function() invoke_go2tv(false, {}) end) +mp.add_key_binding(nil, "go2tv-video", function() invoke_go2tv_on_open_file("-v") end) +mp.add_key_binding(nil, "go2tv-stream", function() invoke_go2tv_on_open_file("-s") end) --- uncomment for debugging: --- if mpv fails to eval this script (e.g. syntax error), then it will fail to quit on launch --- mp.command('quit') +msg.trace("load: complete")