Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora Resources > Guides & Solutions (No Questions)
FedoraForum Search

Forgot Password? Join Us!

Guides & Solutions (No Questions) Post your guides here (No links to Blogs accepted). You can also append your comments/questions to a guide, but don't start a new thread to ask a question. Use another forum for that.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 17th January 2012, 12:52 PM
COKEDUDE Offline
Registered User
 
Join Date: Jan 2011
Posts: 351
linuxfirefox
linux set file associations from the command line

At various times it is helpful to know how to setup file associations from the command line. Sometimes file managers just won't work, other times you may have a corrupted file or bad line in your file. I will give 3 examples.

Pick out out a file of the type of file you want to set.
I picked an avi, m4a, and jpg.
Then query the file to figure out the mimetype syntax.
Code:
xdg-mime query filetype /home/bob/Downloads/vid1.avi
Check what the default program is of that mimetype.
Figure out what the programname.desktop of the program you want to use is. The simplest way to do this is by checking your mimeapps.list file located here. Obviously change your username.
Code:
vi /home/bob/.local/share/applications/mimeapps.list
If that doesn't work try searching for the file with a similar command.
Code:
find / -iname '*vlc.desktop*' 2>/dev/null
If the programname.desktop file has a weird name then you will need to grep for that file. Handbrake has the weirdest file name I have seen so I will use that as my example.
Code:
sudo grep -riI "handbrake" /usr/share/applications/* 2>/dev/null
/usr/share/applications/ghb.desktop:Name=HandBrake
Check what the default program is of that mimetype.
Code:
xdg-mime query default video/x-msvideo
Set the file association.
Code:
xdg-mime default vlc.desktop video/x-msvideo
The examples.
Code:
xdg-mime query filetype /home/bob/Downloads/vid1.avi
xdg-mime query default video/x-msvideo
xdg-mime default vlc.desktop video/x-msvideo
Code:
xdg-mime query filetype /media/3CACE1E0ACE194A4/Anthem.m4a
xdg-mime query default audio/mp4
xdg-mime default vlc.desktop audio/mp4
Code:
xdg-mime query filetype /home/bob/Downloads/shellr.jpg
xdg-mime query default image/jpeg
xdg-mime default gwenview.desktop image/jpeg
Verify that what you were trying to set worked. First check the mimeapps.list. Then use your favorite file manager to verify your work or use xdg-open.
Code:
vi /home/bob/.local/share/applications/mimeapps.list
Code:
xdg-open /home/bob/Downloads/vid1.avi
Reply With Quote
Reply

Tags
associations, command, file, line, linux, set

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Video file properties on the command line? scruffy72 Using Fedora 10 21st September 2012 09:39 AM
Get video file attributes from command line szilagyic Using Fedora 2 17th October 2009 04:29 AM
Command line to get output on a file satimis Programming & Packaging 4 26th June 2005 03:21 PM
How do I edit a file in the command line? BoomerFZ1 Using Fedora 3 5th April 2005 09:28 PM


Current GMT-time: 20:52 (Thursday, 20-11-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat
Aramil Instagram Photos - Nurpur Photos on Instagram - Puerto de la Cruz Photos on Instagram