setting a default application for some selected files

Please post suggestions for improvement of Cinnamon here
https://github.com/linuxmint/Cinnamon
Post Reply
lperg
Level 1
Level 1
Posts: 16
Joined: Fri Nov 23, 2012 12:38 am

setting a default application for some selected files

Post by lperg » Tue Jan 16, 2018 11:16 pm

Linux Mint 18.2 Cinnamon 3.4.6 64-bit
Is it possible to change the default application for some files without changing the global default? Specifically, I need to make a few hundred .html files in two directories open in a browser, instead of the global default of the geany text editor.

Thanks,

-lperg-

User avatar
catweazel
Level 14
Level 14
Posts: 5204
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: setting a default application for some selected files

Post by catweazel » Wed Jan 17, 2018 12:39 am

You can always set the default to the browser while you do the work then set it back to geany when you're done, if you wish.
A new scientific truth does not triumph by convincing its opponents and making them see the light, but rather because its opponents eventually die, and a new generation grows up that is familiar with it. - Max Planck

lperg
Level 1
Level 1
Posts: 16
Joined: Fri Nov 23, 2012 12:38 am

Re: setting a default application for some selected files

Post by lperg » Wed Jan 17, 2018 3:45 pm

catweazel wrote:You can always set the default to the browser while you do the work then set it back to geany when you're done, if you wish.
True, but I would end up doing that all the time because I tend to work on several projects simultaneously.

-lperg-

Cosmo.
Level 23
Level 23
Posts: 17830
Joined: Sat Dec 06, 2014 7:34 am

Re: setting a default application for some selected files

Post by Cosmo. » Wed Jan 17, 2018 6:17 pm

You can use different user accounts with independent setting.

lperg
Level 1
Level 1
Posts: 16
Joined: Fri Nov 23, 2012 12:38 am

Re: setting a default application for some selected files

Post by lperg » Wed Jan 17, 2018 6:46 pm

Cosmo. wrote:You can use different user accounts with independent setting.
No, that would not work: I need both together, html-in-browser for local documentation files, and html-in-editor for web work in progress. What I'd need is to separate the default application from the file type.

-lperg-

User avatar
catweazel
Level 14
Level 14
Posts: 5204
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: setting a default application for some selected files

Post by catweazel » Thu Jan 18, 2018 1:36 am

lperg wrote:
Cosmo. wrote:You can use different user accounts with independent setting.
No, that would not work: I need both together, html-in-browser for local documentation files, and html-in-editor for web work in progress. What I'd need is to separate the default application from the file type.

-lperg-
You can write a simple bash script that uses the mimeopen command. For example, in a terminal I would write:

Code: Select all

$ mimeopen -a /home/username/example.text
That will give the following output:

Code: Select all

Please choose a default application for files of type text/plain

        1) LibreOffice Writer  (libreoffice-writer)
        2) Notepadqq  (notepadqq)
        3) Kate  (org.kde.kate)
        4) Vim  (vim)

use application #
You can put the command into a bash script and pass the file name as a parameter. The -a attribute tells mimeopn to ask what application the file is to be opened with. You can use -d to ask then set the default. See man mimeopen for other options.
A new scientific truth does not triumph by convincing its opponents and making them see the light, but rather because its opponents eventually die, and a new generation grows up that is familiar with it. - Max Planck

lperg
Level 1
Level 1
Posts: 16
Joined: Fri Nov 23, 2012 12:38 am

Re: setting a default application for some selected files

Post by lperg » Thu Jan 18, 2018 3:18 pm

catweazel wrote: You can write a simple bash script that uses the mimeopen command.
That looks promising, thanks. I did not know about this program.
-lperg-

User avatar
catweazel
Level 14
Level 14
Posts: 5204
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: setting a default application for some selected files

Post by catweazel » Fri Jan 19, 2018 1:37 am

lperg wrote:
catweazel wrote: You can write a simple bash script that uses the mimeopen command.
That looks promising, thanks. I did not know about this program.
-lperg-
You're welcome.
A new scientific truth does not triumph by convincing its opponents and making them see the light, but rather because its opponents eventually die, and a new generation grows up that is familiar with it. - Max Planck

Post Reply

Return to “Cinnamon”