mpv: add mpv-websocket support

Note that we use a simplified version of run_websocket_server.lua since
we don't depend on toggling functionality.
This commit is contained in:
Donovan Glover 2025-05-30 23:02:55 -04:00
parent 4e6131ad81
commit 826cfc0f4b
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65

View File

@ -1,5 +1,18 @@
{ lib, pkgs, ... }: {
lib,
pkgs,
nixosConfig,
...
}:
let
inherit (nixosConfig._module.specialArgs) nix-config;
inherit (lib) getExe;
inherit (nix-config.packages.${pkgs.system}) mpv-websocket;
input-ipc-server = "/tmp/mpv-socket";
in
{ {
programs.mpv = { programs.mpv = {
enable = true; enable = true;
@ -33,6 +46,8 @@
osd-duration = 750; osd-duration = 750;
autofit = "65%"; autofit = "65%";
inherit input-ipc-server;
}; };
bindings = { bindings = {
@ -42,25 +57,45 @@
}; };
}; };
xdg.configFile."mpv/script-opts/uosc.conf".text = lib.concatStrings [ xdg.configFile = {
"opacity=" "mpv/scripts/run_websocket_server.lua".text = # lua
",timeline=0.1" ''
",position=0.2" mp.command_native_async({
",chapters=0.075" name = "subprocess",
",slider=0.1" playback_only = false,
",slider_gauge=0.2" capture_stdout = true,
",controls=0" capture_stderr = true,
",speed=0.2"
",menu=1" args = {
",submenu=0.4" "${getExe mpv-websocket}",
",border=1" "-m",
",title=1" "${input-ipc-server}",
",tooltip=1" "-w",
",thumbnail=1" "6677",
",curtain=0.8" },
",idle_indicator=0.8" })
",audio_indicator=0.5" '';
",buffering_indicator=0.3"
",playlist_position=0.8" "mpv/script-opts/uosc.conf".text = lib.concatStrings [
]; "opacity="
",timeline=0.1"
",position=0.2"
",chapters=0.075"
",slider=0.1"
",slider_gauge=0.2"
",controls=0"
",speed=0.2"
",menu=1"
",submenu=0.4"
",border=1"
",title=1"
",tooltip=1"
",thumbnail=1"
",curtain=0.8"
",idle_indicator=0.8"
",audio_indicator=0.5"
",buffering_indicator=0.3"
",playlist_position=0.8"
];
};
} }