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 = {
enable = true;
@ -33,6 +46,8 @@
osd-duration = 750;
autofit = "65%";
inherit input-ipc-server;
};
bindings = {
@ -42,25 +57,45 @@
};
};
xdg.configFile."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"
];
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="
",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"
];
};
}