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,7 +57,26 @@
}; };
}; };
xdg.configFile."mpv/script-opts/uosc.conf".text = lib.concatStrings [ xdg.configFile = {
"mpv/scripts/run_websocket_server.lua".text = # lua
''
mp.command_native_async({
name = "subprocess",
playback_only = false,
capture_stdout = true,
capture_stderr = true,
args = {
"${getExe mpv-websocket}",
"-m",
"${input-ipc-server}",
"-w",
"6677",
},
})
'';
"mpv/script-opts/uosc.conf".text = lib.concatStrings [
"opacity=" "opacity="
",timeline=0.1" ",timeline=0.1"
",position=0.2" ",position=0.2"
@ -63,4 +97,5 @@
",buffering_indicator=0.3" ",buffering_indicator=0.3"
",playlist_position=0.8" ",playlist_position=0.8"
]; ];
};
} }