dirtyhawk/stata-integration

Make Stata default application of file type .dta (etc.)

Opened this issue · 1 comments

Although it is perhaps somewhat lengthy I will try to explain the problem and what I did (I started a thread in the StataForum already, but the recommendations did not help me to solve the problem, see: https://www.statalist.org/forums/forum/general-stata-discussion/general/1539226-linux-make-stata-default-application-of-file-type-dta-etc ):

  1. I did install the proprietary software Stata (version 16.1) , it is installed as "xstata-se" in /usr/local/stata16 . Originally, when I started the program, it's icon appeared in the bar of active programs and if I started a second instance of Stata a second icon appeared (as it should). However, files with the extension .ado, .cht, .dta, .do, and .smcl were not associated with Stata. For example, Linux treated .dta-files as .html-files.

  2. I tried to associate the file exension .do using Ubuntu's "nautilus" file manager. However, this was not possible because Linux does not recognize Stata as an installed application. Therefore, I used the file manager Krusader as follows: Right-click on the .do-file, -> open with -> other -> [selection of the program /usr/local/stat16/xstata-se] + check of "remember application association for all files of type ...". It solved the issue of associating Stata files with Stata, but since then when starting Stata the program does not appear with its original icon in the bar of active programs but only with a Linux generic icon. Additionally, when starting multiple instances of Stata, they are all "collected" under this icon, thus they do not appear with separate icons anymore.

  3. I got the advice to configure mime types, but I did not know how to do.

  4. I got the advice to run the script "stata-integration.bin" from GitHub (see https://github.com/dirtyhawk/stata-integration ) and this solved the problem: Files with an extension that should be opened by Stata when using double-clicks now appeared with a Stata icon and when starting Stata each instance appeared with the correct icon in the bar of active programs. Hooray!

  5. However, I have another version (17.0) of Stata (also named "xstata-se") installed at /usr/local/stata17 . Because the Stata files were associated only with Stata 16.1, again I tried to associated files with the extension .do permanently with "usr/local/stata17/xstata-se" as described in (2). However, since then the old problem as described in (2) appeared again. I tried to re-run the script "stata-integration.bin", but this time it did not solve the problem anymore! [By the way: Again, I can't even associate .dta files with Stata because this extension is associted with .html-files (which I can't change), but this is a secondary issue.]

Is there any idea way I can get the proper behavior back as described in (4)? Meanwhile I learned that I can only associate one specific version of Stata (16.1 or 17.0) permanently with Stata files, but I would be happy if I could achieve this.

Hi @DEnzmann ,

for some reason, I didn't see you inquiry for quite a while, sorry about that. The problem is that in Linux desktop environments (as long as they follow the freedesktop specification), any application can register as application capable of opening a specific mime type. This is what my script, essentially, does: it registers Stata as application capable of opening .dta files, and all the other file types that Stata knows about.

When running stata-integration.bin several times for several instances (like in your case: several versions), all those instances get registered. If I remember my own script correctly, the last run will persist the default application, though. So if you run for 17 first, and for 16 afterwards, 16 remains as the default application.

Under all major desktop environments, you can see the default with the command xdg-mime:

xdg-mime query default application/x-stata-do

stata-stata17_windowed.desktop

You can change the default by running:

xdg-mime default stata-stata17_windowed.desktop application/x-stata-do

Unfortunately, this has to be repeated for all relevant mimetypes you want to reset the default for.