After looking at this mpv github issue, I tried adding the audio-display
option to my home-manager config:
{ ... }: {
programs.mpv = {
enable = true;
config = {
input-ipc-server = "/tmp/mpvsocket";
single-instance-behavior = "replace";
force-window = "no";
audio-display = "no";
speed = "1.5";
};
};
}
To make sure the player was using the config, I included the speed
option. Playback did change to 1.5x, but it didn’t respect the audio-display
option and a window still opened.
According to the man page for mpv, setting audio-display=no
should “Disable display of video entirely when playing audio files.” It doesn’t mention anything about keeping the “window” from opening up.
I’d like to just use my media keys to control mpv in the background while playing audio files - no need for a gui window on my laptop running hyperland, atm. Does anyone know of a way to keep the player from opening a window?
1 Like
How are you starting mpv? If I run mpv foo.flac
on the command line, I don’t get an mpv window, but if I double-click a FLAC file in Thunar, I do. I suspect this is related to the --player-operation-mode=pseudo-gui
flag in mpv.desktop
.
1 Like
I am able to play audio files from terminal without it opening a player window, but it would be nice if the player window also didn’t open with my file manager, yazi. Thanks for confirming that it also opens a window from Thunar.
It looks like the only other option in the man page for the player-operation-mode
flag is “cplayer” but it isn’t clear if that would cause a player to open elsewhere, like in your browser.
I tried adding the following to home.nix and logged out and logged back in, but that didn’t work.
xdg.desktopEntries.mpv = {
name = "mpv Media Player";
icon = "mpv";
exec = "mpv -- %U";
terminal = false;
type = "Application";
categories = ["AudioVideo" "Audio" "Video" "Player" "TV"];
mimeType = ["application/ogg" "application/x-ogg" "application/mxf" "application/sdp" "application/smil" "application/x-smil" "application/streamingmedia" "application/x-streamingmedia" "application/vnd.rn-realmedia" "application/vnd.rn-realmedia-vbr" "audio/aac" "audio/x-aac" "audio/vnd.dolby.heaac.1" "audio/vnd.dolby.heaac.2" "audio/aiff" "audio/x-aiff" "audio/m4a" "audio/x-m4a" "application/x-extension-m4a" "audio/mp1" "audio/x-mp1" "audio/mp2" "audio/x-mp2" "audio/mp3" "audio/x-mp3" "audio/mpeg" "audio/mpeg2" "audio/mpeg3" "audio/mpegurl" "audio/x-mpegurl" "audio/mpg" "audio/x-mpg" "audio/rn-mpeg" "audio/musepack" "audio/x-musepack" "audio/ogg" "audio/scpls" "audio/x-scpls" "audio/vnd.rn-realaudio" "audio/wav" "audio/x-pn-wav" "audio/x-pn-windows-pcm" "audio/x-realaudio" "audio/x-pn-realaudio" "audio/x-ms-wma" "audio/x-pls" "audio/x-wav" "video/mpeg" "video/x-mpeg2" "video/x-mpeg3" "video/mp4v-es" "video/x-m4v" "video/mp4" "application/x-extension-mp4" "video/divx" "video/vnd.divx" "video/msvideo" "video/x-msvideo" "video/ogg" "video/quicktime" "video/vnd.rn-realvideo" "video/x-ms-afs" "video/x-ms-asf" "audio/x-ms-asf" "application/vnd.ms-asf" "video/x-ms-wmv" "video/x-ms-wmx" "video/x-ms-wvxvideo" "video/x-avi" "video/avi" "video/x-flic" "video/fli" "video/x-flc" "video/flv" "video/x-flv" "video/x-theora" "video/x-theora+ogg" "video/x-matroska" "video/mkv" "audio/x-matroska" "application/x-matroska" "video/webm" "audio/webm" "audio/vorbis" "audio/x-vorbis" "audio/x-vorbis+ogg" "video/x-ogm" "video/x-ogm+ogg" "application/x-ogm" "application/x-ogm-audio" "application/x-ogm-video" "application/x-shorten" "audio/x-shorten" "audio/x-ape" "audio/x-wavpack" "audio/x-tta" "audio/AMR" "audio/ac3" "audio/eac3" "audio/amr-wb" "video/mp2t" "audio/flac" "audio/mp4" "application/x-mpegurl" "video/vnd.mpegurl" "application/vnd.apple.mpegurl" "audio/x-pn-au" "video/3gp" "video/3gpp" "video/3gpp2" "audio/3gpp" "audio/3gpp2" "video/dv" "audio/dv" "audio/opus" "audio/vnd.dts" "audio/vnd.dts.hd" "audio/x-adpcm" "application/x-cue" "audio/m3u" "audio/vnd.wave" "video/vnd.avi"];
};
In the meantime, here’s my hacky workaround:
#hyprland config
windowrule = [
"opacity 0.0 0.0, (mpv)$"
"size 1% 1%, (mpv)$"
"move 100% 100%, (mpv)$"
"float, (mpv)$"
];
It basically uses hyprland to open the window in a 1% wide by 1% high floating pane that opens in the corner with no opacity. The only downside of this is that mpv still takes the window’s focus even though you can’t see it.
This fixes it for yazi. I imagine other file managers that also have this problem must also use the --force-window
flag, and would also need a custom config to overwrite the run command for audio files (similar to the home-manager config below).
{ nixpkgs-unstable, pkgs, ... }: {
programs.yazi = {
enable = true;
package = nixpkgs-unstable.legacyPackages.${pkgs.system}.yazi;
enableBashIntegration = true;
settings = {
opener.play = [
{ run = "mpv \"$@\""; }
];
};
}
so basically what you wanted to do is to start mpv
in a terminal? and also without the album cover / image rendering? like a normal music player?
didnt the… launching it in the terminal work?
or was that the problem? 
anyway, i’d also like to share what i did for my yazi config - i use mpv both for audio, video and image viewing in TUI:
this is just a snippet of my collection of like 20 openers for play
only
three little disclaimers (ugh im so lazy expplaining this): 1. for this example im only using the play
opener, but you should create your own custom ones associated with each mime, such as image/*
, audio/*
and video/*
. 2. because my config is very dangerous for anyone to look at, i tried to shorten this tenfold! 3. i highly recommend mpvc if you like TUI stuff!
audio/*
(audio/\*
): (if you want pixel art unicode cover preview use: mpv --vo=tct "$@"
, for ASCII use mpv --vo=caca "$@"
, otherwise use graphical mpv "$@"
)
programs.yazi.settings.opener.play = [
{
run = ''mpv --vid=no "$@"''; # no cover
desc = "MPV";
block = true;
for = "linux";
}
];
video/*
(video/\*
):
programs.yazi.settings.opener.play = [
{
run = ''mpv "$@"''; # use '--vo=tct' for pixelated unicode video lol
desc = "MPV";
block = true;
for = "linux";
}
];
image/*
(image/\*
):
programs.yazi.settings.opener.play = [
{
run = ''mpv --vo=tct "$@"''; # remove '--vo=tct' if ur terminal supports graphical output
desc = "MPV";
block = true;
for = "linux";
}
];
haha, felt like sharing… but yeah, anyway… once again, perhaps mpvc is a better option!
sorry if i completely misunderstood what’s going on here 
1 Like
@frozen.frog23 thanks for sharing your config and usage. Always cool to see how other people are configurating and using the same software.
I was actually trying to get mpv to open without a window from yazi, since I just use it for playing audio on my laptop which has media keys. No need to see album art, track time, or any of that. Just like to put something on in the background while I’m working.
It’s been working well so far with my fix above. My only complaint is that you can’t replace the mpv instance when opening new files without sacrificing functionality - like I explain here. My not so great workaround: pause player and start a new instance to play another song, and then use a keybind to kill all instances when I’m done. Not great, but I guess it works.