Tuesday, October 3, 2023
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 764  / 2 Years ago, sat, july 17, 2021, 1:59:39

I know that there are some files /etc/gnome/defaults.list that store mime associations and are in format that should make editing them possible.



But I am looking for a way that will handle at least one of following problems




  • this file is in format that is reasonable to parse. Still, using API that somebody made and hopefully tested will save some time and problems with bugs

  • it would be great to have API aware about location of that file depending on OS version, OS etc. Even crashing with "this is not supported" would be preferable to script editing something that is no longer used



I want to fully automate my installation of Ubuntu - setting file associations to correct one is intended to be part of that.



Even automated/semi-automated (like documentation) way to find place storing file associations would be welcome.



how can I change file association globally? mentions /usr/share/gnome/applications/defaults.list, /usr/share/applications/defaults.list and /usr/share/applications/mimeapps.list See also Which default.list should I modify for default applications and what are the differences between the two? (so I would prefer to automate at least locating the file)


More From » 18.04

 Answers
5

Following works in some cases, but not all:


to see mimetype:
file --mime-type -b sudolightburn.sh


to see current association:
xdg-mime query default text/plain


to change association:
xdg-mime default codium.desktop text/plain


In case someone would be interested, I have an ansible role using this to setup sane default programs: https://github.com/matkoniecz/recovery-with-ansible/tree/master/roles/set_default_programs_for_file_types


[#14652] Sunday, July 18, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
antorchestr

Total Points: 92
Total Questions: 111
Total Answers: 120

Location: Jordan
Member since Wed, Jun 17, 2020
3 Years ago
antorchestr questions
;