I would like to set the default video player from the command line. Taking xvideos
as an example, I tried replacing all references to Totem by xvideos
in the defaults.list
file:
mv /usr/share/applications/defaults.list /usr/share/applications/defaults.list.old.totem
sed 's/Totem/xvideos/' /usr/share/applications/defaults.list.old.totem > /usr/share/applications/defaults.list
The contents of this file now look like:
$ cat /usr/share/applications/defaults.list | grep xvideos
application/vnd.rn-realmedia=org.gnome.xvideos.desktop
application/x-extension-m4a=org.gnome.xvideos.desktop
application/x-extension-mp4=org.gnome.xvideos.desktop
application/x-matroska=org.gnome.xvideos.desktop
application/x-shockwave-flash=org.gnome.xvideos.desktop
audio/3gpp=org.gnome.xvideos.desktop
audio/ac3=org.gnome.xvideos.desktop
audio/AMR=org.gnome.xvideos.desktop
audio/AMR-WB=org.gnome.xvideos.desktop
audio/basic=org.gnome.xvideos.desktop
audio/midi=org.gnome.xvideos.desktop
audio/mp4=org.gnome.xvideos.desktop
audio/mpeg=org.gnome.xvideos.desktop
audio/mpegurl=org.gnome.xvideos.desktop
audio/prs.sid=org.gnome.xvideos.desktop
audio/vnd.rn-realaudio=org.gnome.xvideos.desktop
audio/x-ape=org.gnome.xvideos.desktop
audio/x-gsm=org.gnome.xvideos.desktop
audio/x-it=org.gnome.xvideos.desktop
audio/x-m4a=org.gnome.xvideos.desktop
audio/x-matroska=org.gnome.xvideos.desktop
audio/x-mod=org.gnome.xvideos.desktop
audio/x-ms-asf=org.gnome.xvideos.desktop
audio/x-ms-asx=org.gnome.xvideos.desktop
audio/x-ms-wax=org.gnome.xvideos.desktop
audio/x-ms-wma=org.gnome.xvideos.desktop
audio/x-musepack=org.gnome.xvideos.desktop
audio/x-pn-aiff=org.gnome.xvideos.desktop
audio/x-pn-au=org.gnome.xvideos.desktop
audio/x-pn-realaudio=org.gnome.xvideos.desktop
audio/x-pn-realaudio-plugin=org.gnome.xvideos.desktop
audio/x-pn-wav=org.gnome.xvideos.desktop
audio/x-pn-windows-acm=org.gnome.xvideos.desktop
audio/x-realaudio=org.gnome.xvideos.desktop
audio/x-real-audio=org.gnome.xvideos.desktop
audio/x-sbc=org.gnome.xvideos.desktop
audio/x-speex=org.gnome.xvideos.desktop
audio/x-tta=org.gnome.xvideos.desktop
audio/x-wav=org.gnome.xvideos.desktop
audio/x-wavpack=org.gnome.xvideos.desktop
audio/x-xm=org.gnome.xvideos.desktop
image/vnd.rn-realpix=org.gnome.xvideos.desktop
misc/ultravox=org.gnome.xvideos.desktop
video/3gpp=org.gnome.xvideos.desktop
video/dv=org.gnome.xvideos.desktop
video/fli=org.gnome.xvideos.desktop
video/flv=org.gnome.xvideos.desktop
video/mp2t=org.gnome.xvideos.desktop
video/mp4=org.gnome.xvideos.desktop
video/mp4v-es=org.gnome.xvideos.desktop
video/mpeg=org.gnome.xvideos.desktop
video/msvideo=org.gnome.xvideos.desktop
video/ogg=org.gnome.xvideos.desktop
video/quicktime=org.gnome.xvideos.desktop
video/vivo=org.gnome.xvideos.desktop
video/vnd.divx=org.gnome.xvideos.desktop
video/vnd.rn-realvideo=org.gnome.xvideos.desktop
video/vnd.vivo=org.gnome.xvideos.desktop
video/webm=org.gnome.xvideos.desktop
video/x-anim=org.gnome.xvideos.desktop
video/x-avi=org.gnome.xvideos.desktop
video/x-flc=org.gnome.xvideos.desktop
video/x-fli=org.gnome.xvideos.desktop
video/x-flic=org.gnome.xvideos.desktop
video/x-flv=org.gnome.xvideos.desktop
video/x-m4v=org.gnome.xvideos.desktop
video/x-matroska=org.gnome.xvideos.desktop
video/x-mpeg=org.gnome.xvideos.desktop
video/x-ms-asf=org.gnome.xvideos.desktop
video/x-ms-asx=org.gnome.xvideos.desktop
video/x-msvideo=org.gnome.xvideos.desktop
video/x-ms-wm=org.gnome.xvideos.desktop
video/x-ms-wmv=org.gnome.xvideos.desktop
video/x-ms-wmx=org.gnome.xvideos.desktop
video/x-ms-wvx=org.gnome.xvideos.desktop
video/x-nsv=org.gnome.xvideos.desktop
video/x-ogm+ogg=org.gnome.xvideos.desktop
video/x-theora+ogg=org.gnome.xvideos.desktop
video/x-totem-stream=org.gnome.xvideos.desktop
x-content/video-dvd=org.gnome.xvideos.desktop
x-content/video-vcd=org.gnome.xvideos.desktop
x-content/video-svcd=org.gnome.xvideos.desktop
However, videos are still being opened with Totem by default, say, if I double click on a movie file in the file manager.
How else can this be achieved?
After about an hour of messing around with this I got this working for me, I'm running Ubuntu 16.04.1, I don't have
xvideos
I have vlc installed, so you can try simply substitutingvlc
for your player of choice.Heres the command I run at a prompt
running the above command produces
Now going to nautilus and double clicking a
mp4
file it is launched invlc
. I didn't need to hit F5 or logout, it seems~/.local/share/applications/defaults.list
is read on every invocation.reference - https://unix.stackexchange.com/a/41196/106525
In a terminal, First grab all the reference of totem.desktop in a variable and then iterate the variable to set default. For example, if your desired applications .desktop file is
xvideo.desktop
, Go to/usr/share/applications/
do these in terminalDon't forget to refresh your desktop by pressing
F5
, though may not required. If it still doesn't seem to have changed log out of the system and the log in again.As of Ubuntu 18.04, when you change a default application in Settings or change a file association in Files, it gets stored in
~/.config/mimeapps.list
. To change all video files from Totem to VLC in the same way as the GUI does, you can use: