6

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?

0

3 Answers 3

5

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 substituting vlc for your player of choice.
Heres the command I run at a prompt

% sed -n '
1i[Default Applications]
/^video/{
s/Totem/vlc/
s/org\.gnome\.//p
}' /usr/share/applications/defaults.list > ~/.local/share/applications/defaults.list

running the above command produces

% cat ~/.local/share/applications/defaults.list
[Default Applications]
video/3gpp=vlc.desktop
video/dv=vlc.desktop
video/fli=vlc.desktop
video/flv=vlc.desktop
video/mp2t=vlc.desktop
video/mp4=vlc.desktop
video/mp4v-es=vlc.desktop
video/mpeg=vlc.desktop
video/msvideo=vlc.desktop
video/ogg=vlc.desktop
video/quicktime=vlc.desktop
video/vivo=vlc.desktop
video/vnd.divx=vlc.desktop
video/vnd.rn-realvideo=vlc.desktop
video/vnd.vivo=vlc.desktop
video/webm=vlc.desktop
video/x-anim=vlc.desktop
video/x-avi=vlc.desktop
video/x-flc=vlc.desktop
video/x-fli=vlc.desktop
video/x-flic=vlc.desktop
video/x-flv=vlc.desktop
video/x-m4v=vlc.desktop
video/x-matroska=vlc.desktop
video/x-mpeg=vlc.desktop
video/x-ms-asf=vlc.desktop
video/x-ms-asx=vlc.desktop
video/x-msvideo=vlc.desktop
video/x-ms-wm=vlc.desktop
video/x-ms-wmv=vlc.desktop
video/x-ms-wmx=vlc.desktop
video/x-ms-wvx=vlc.desktop
video/x-nsv=vlc.desktop
video/x-ogm+ogg=vlc.desktop
video/x-theora+ogg=vlc.desktop
video/x-totem-stream=vlc.desktop

Now going to nautilus and double clicking a mp4 file it is launched in vlc. 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

4
  • It seems it is all about setting the defaults.list file in the right place. Aug 9, 2016 at 14:41
  • Changing with xdg-mime automatically writes the entry in that file.
    – Anwar
    Aug 9, 2016 at 16:11
  • @LuísdeSousa for me - it was all about applying the section heading [Default Applications] into the beginning of the declaration block. It didn't work until I did that. Aug 9, 2016 at 22:15
  • I just copied the defaults.list file I created in the question into ~/.local/share/applications/defaults.list and it immediately started working. Aug 10, 2016 at 6:50
2

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 terminal

videos="$(cat defaults.list | grep Totem.desktop | cut -d '=' -f 1)"
for i in "$videos"; do xdg-mime default xvideo.desktop "$i"; done

Don'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.

3
  • 1
    well there it is ^_^
    – Zanna
    Aug 9, 2016 at 10:10
  • This answer looks good, but does not do it yet. I even logged out and back in, but Totem remains in control of all video file types. Aug 9, 2016 at 12:09
  • try removing the mimeinfo.cache file in ~/.local/share/applications directory
    – Anwar
    Aug 9, 2016 at 12:34
2

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:

sed -n '1p; s/org\.gnome\.Totem\.desktop/vlc\.desktop/p' /usr/share/applications/defaults.list > ~/.config/mimeapps.list
sed '1s/\[Default Applications\]/\n\[Added Associations\]/; 2,$s/$/;/' ~/.config/mimeapps.list >> ~/.config/mimeapps.list

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .