Understanding File Associations in LXDE and Pcmanfm
Total Page:16
File Type:pdf, Size:1020Kb
Understanding file associations in LXDE and PC... https://lkubaski.wordpress.com/2012/10/29/under... The skiing cube Random geeky stuff Understanding file associations in LXDE and PCManFM OCTOBER 29, 2012 6 COMMENTS (HTTPS://LKUBASKI.WORDPRESS.COM/2012/10/29/UNDERSTANDING- FILE-ASSOCIATIONS-IN-LXDE-AND-PCMANFM/#COMMENTS# O$ “u'()$*+,'(-'. how PCManFM decides w/-2/ program to launch w/)' you d0&75)-click on a f-5): O$ “u'()$*+,'(-'. the list o9 sugg)*+)( pro.$,ms when y0& r-./t-click on a file in PCManFM: O$ “making sense of the mime-'fo.cac/e, defaults.list and m-4eapps.list crazyn)**: The problem Create a text fil) (text.txt) f-le in PCManFM and right click on it: PCManFM d-*35,6s a list of possible application that c,' open th) file: (/++3s://lkubask-.f-les.w0$(press.com/2012/10/sug.)*+)(1.png# Now i9 I double-click on the text.txt file, abiword (the f-rst item /-./5-./+)( i' the screenshot above) is going t0 be l,&'2/)(. Whe$) does th-s “A7-Word – ged-t- Leafpad” list co4e from ? I want to use ged-t instead of AbiWo$( when d0&75)-clicking on the f-le: h01 can I c/,'.) this ? I want my text f-le to be ope')( by a program that is not li*+)(: how c,' I do this ? Whe$) i' the w0$5( is C,$4en SanDiego ? Sit back and relax, I’m g0-'g to tell you the whole story. At the beginning, there was the .desktop files 1 of 6 2015-07-31 20:59 These f-les are m,-'56 used t0 sp)2-96 wh-ch e5)4ents are g0-'g to be d-*35,6)d in the LXDE star+ menu and o' your desktop. Ch)28 Understanding file associations in LXDE and PC... https://lkubaski.wordpress.com/2012/10/29/under... my creating L!DE shortcuts (/++3s://lkubask-.wordpress.com/2012/06/29/,((-'g-lxde-start-menu-and-()*8top-shortcuts/) post for more information. Then there was mimeinfo.cache This file is loc,+)d in /u*$/share/ap35-2,+-0's/mime-'fo.cac/e and it -s a basically a raw rev)$*) c,2/e for the .desk+03 i'formation. Check this link (/++3://w-8-.debian.org/MIME) f0$ more i'formation. More preci*)5y, each .desktop file on your system (which can be l02,+)( either in /usr/share/applications, in /usr/local/sh,$) /app5-2,+-0's or in ~/.local/share/,335-cations) can 20'+,-' a “Mi4eT6pe” attribute w/-2/ states the mimetype that the program ,**02-,+)d to the .desktop fil) c,' handle. On my Fed0ra installati0', I h,=e 3 t)<t editors: Abiword, L),93,( and ged-+ and e,2/ one of t/)4 c,' open f-les that have a text/plain mimetype: 1 [laurent@localhost applications]$ cat fedora-abiword.desktop | grep text/plain 2 MimeType=application/x-abiword;text/x-abiword;text/x-xml-abiword;text/plain; 3 4 [laurent@localhost applications]$ cat gedit.desktop | grep text/plain 5 MimeType=text/plain; 6 7 [laurent@localhost applications]$ cat fedora-leafpad.desktop | grep text/plain 8 MimeType=text/plain; Now i9 I h,=e a look in m-4)-'fo.cache, I can find the reverse mapping that we just talked about: 1 [laurent@localhost applications]$ cat mimeinfo.cache | grep text/plain 2 text/plain=fedora-abiword.desktop;gedit.desktop;fedora-leafpad.desktop; So this translates to “any fil) with a te<t/35ain m-4)+63) c,' be opened u*-'g either abiword, ged-t or leafpad”. Astute readers w-ll notic) that: This list (abiw0$( + gedit + leafpad) is exactly the one displayed in PCManFM when I right click on a file (see screensh0+ above). The first item in th-s list (in my case: abiword) is the program that is laun2/ed w/)' I double-click on a text fil) i' PCManFM. How)=)r, editing th-s m-4ecache.info f-le (+0 2/ange the orde$ of the .desktop f-les that are assoc-,+)( with the text/plain mime+63)# is not what you want to do. The truth is you may lose all your c/,'.)s after install-'./removing a new L-'ux pac8age. This is be2,&se this fil) is g)')$,+)( by laun2/-'g the “update-desktop-(,+,7,*)” utility. This tool parses all your .de*8top fil)s and .)nerates the mimeinfo.c,2/e fil)… more or l)ss each time you i'*+,5l a new package. T/-s is where the defaults.list files join th) 3,$+6 Here comes defaults.list ()faults.list is a file where you conf-.ure the default program that should be used to open a file. To be v)$6 speci9-c, th-s is wh)$) you conf-.ure the d)9,&5t “mime type -> .desk+03 file” associatio'. Like .desktop fil)s, you can have a d)9,&5ts.list fil) i' any of the follo1ing locations (you can e=)' have 3 files: one at e,2/ location). /usr/share/applicati0'* /usr/local/share/applications ~/.local/share/applications First, there -s a global defaults.list f-le loc,+)d in /u*$/share/ap35-2,+-0's and then you can have one for each user, located in ~/.local/share/,335-2,+-0's. As you can guess, the “user-level” fil) has higher priority than the “g5obal one”. 2 ofIf 6I on56 have a /usr/share/applications/()9aults.list file that contains a “t)<t/35,-' -> gedit.desktop” map3-'g, then2015-07-31 doub5e- 20:59 Understanding file associations in LXDE and PC... https://lkubaski.wordpress.com/2012/10/29/under... 25icking on a text fil) i' PCManFM will open ged-t, no matter what the or(ering of m-4einfo.cache is: 1 [laurent@localhost applications]$ cat /usr/share/applications/defaults.list | grep text/plain 2 text/plain=gedit.desktop But i9 I also have a ~/.local/share/,335-cations/default.list 9-5e that contains a “text/plain -> fedora-leafpad.desktop” mapping, +/)n dou75)-clicking on a text file in PCManFM will open leafpad (*-'2) this fil) has “higher pri0$-+y” than the f-les in the 2 other 502,+-0'*#. 1 [laurent@localhost applications]$ cat ~/.local/share/applications/defaults.list | grep text/plain 2 text/plain=fedora-leafpad.desktop But wait, the$) is m0$) ! The mimeinfo.cache, the defaults.list and the mimeapps.list Yes that’s tr&e, one m0$) file t0 b0+her you (did I men+-0' “cr,;6ness” at the beg-'ning of this post ?#. Now i9 you think that ~/.local/share/,335-cations/d)9,&5ts.list has higher priority than /usr/sh,$)/applications/d)9,&5ts.list 1/-2/ has higher pr-0$-+y than /usr/sh,$)/applications/m-4einfo.cache”, you would still be i'20rrect be2,&se ~/.local/share /applications/mimeapps.list has even higher priority than all these bastards. mimeapps.list allows you to: ,(d even more “ri.ht-click” opt-ons to PCManFM right c5-28 men& set the default program f0r a m-4)+63) (exactl6 l-8) i' def,&5ts.5-*+# Although I’m not aware of any tool to h)5p you de,5 w-+/ defaults.list file, the$) ar) at l)ast 2 opti0's to help you w-+/ mimeapps.l-*+ OK, so 5)+@s say that you would like to open your text file with yet another pr0.$,4 that is not listed in the PCManFM right-25-28 4)nu. Just choose the “O3)' with…” option and select an app5-2,+-0'. In my case, I@55 choose “Xpad”, and I’ll c/00*) the “set *)5)2+)( application as default” optio': (/++3s://lkubask-.f-les.w0$(press.com/2012/10/xpad.pn.# And the$) you are, xpad is now part of your right-2lick menu: 3 of 6 2015-07-31 20:59 Understanding file associations in LXDE and PC... https://lkubaski.wordpress.com/2012/10/29/under... (/++3s://lkubask-.f-les.w0$(press.com/2012/10/sug.)*+)(21.png# Be/-'( the scene, PCManFM cr)ated a mimeapps.list fil): 1 laurent@localhost applications]$ cat ~/.local/share/applications/mimeapps.list 2 3 [Added Associations] 4 text/plain=fedora-xpad.desktop; 5 6 [Default Applications] 7 8 text/plain=fedora-xpad.desktop An0+/er way to gene$,+e this fil) is to use the xdg-m-4e tool w-+/ “x(g-mime d)9,&5t fedora-xpad.desktop text/plai': So let’s recap The list of pro.ram that is d-*35,6)d when right-clicking on a fil) in PCManFM is the combination of: mimeinfo.cache mimeapps.list The default program that is l,&'2/)( when you double-click on a file in PCManFM is (9-$st match w-'s): The one from ~/.local/share/,335-2,+-0's/mimeapps.li*+ The one from ~/.local/share/,335-2,+-0's/defaults.li*+ The one from /usr/5ocal/share/,335-2,+-0's/defaults.li*+ The one from /usr/share/applications/()9aults.l-*+ The first one f$04 /usr/share/applic,+-ons/4-4)-'90.2,2/) Laurent KUBASKI 4 of 6 2015-07-31 20:59 Understanding file associations in LXDE and PC... https://lkubaski.wordpress.com/2012/10/29/under... You May Like 1. 83 Rare Historical Photos That Will Leave You Speechless 2 months ago checkthisyo.com Check This, Yo! FILED UNDER LXDE TAGGED WITH LXDE ! out lkubaski 11w.kubaski.com 6 Responses to Understanding file associations in LXDE and PCManFM Cor says: April 21, 2013 at 12:37 pm Very w)55 explai')(, thank*G Reply Maur$cio says: May 9, 2013 at 9:28 pm hi ! i use lubuntu, and i h,=) a pro75)4: with p24,'94, howto i open selected f-les ()<,4ple: multipl) v-()o files, or m&5tiple text files) ? 1/en i select multiple fil)s, and hi+ , pc4,'9m opens o'56 the last on the selected list.