3

I want graphical applications such as transmission-gtk and Firefox to open up directories with Midnight Commander through new instances of my default terminal emulator running on Debian.

I've noticed that every time I try to open a directory in various X11/GTK applications, they rather turn to my Firefox browser to show the path, and not to my file manager - MC, including Firefox itself.

I don't know what's wrong with my mimes because Midnight Commander is indeed flagged as a FileManager, and it is the only dedicated file manager that's installed on my system.

/usr/share/applications/mc.desktop:

Categories=ConsoleOnly;Utility;FileManager;System;FileTools;
Keywords=file manager;console;

My mimeinfo.cache is present at the same directory as well, however it has no mention of mc.desktop at all.

How can I set Midnight Commander as my default file manager to be used for opening and browsing filesystem paths? I'm using Linux Debian 10 with X11 but without a desktop environment.

  • I have no used debian in some time, but have you read this article? – number9 Jan 7 '19 at 0:45
  • @number9 I've tried xdg-mime default mc.desktop inode/directory (as mentioned in this article) and now basically GUI apps freeze the moment I try to open any directory through them, and I have to kill them through htop. – David von Tamar Jan 7 '19 at 1:46
  • Ugh. I had an issue similar to that with a debian/ubuntu derivative. Truth be told after countless hours of pain, I backed up my home dir and reinstalled and fixed it by using a different method, which is not like me. What happens if you try to default it back to the stock file manager? – number9 Jan 7 '19 at 2:30
  • @number9, Firefox was used as my fallback "file manager" so I set it back to firefox.desktop and now it works just as before, all directories are opened via Firefox. – David von Tamar Jan 7 '19 at 4:07
2

Create the file ~/.local/share/applications/mc.desktop with contents

[Desktop Entry]
Name=Midnight Commander
MimeType=inode/directory
Exec=mc %F
Terminal=true
Type=Application
Categories=FileManager

Notice the line Terminal=true, maybe you have missed that. MC needs to be run inside a terminal to work, differently from many other applications, as we well know.

Then issue xdg-mime default mc.desktop inode/directory.

I tested it on Firefox (by going to Downloads and then clicking the folder icon to open an item in its directory) and it worked like a charm.

Edit: The above procedure still does not work for some applications (e.g., Telegram and GNOME's Disk Usage Analyzer). Apparently, some (1) ignore or don't cope with Terminal=true, while others (2) pass a file URI scheme as the file path.

To solve both issues at once, try this mc.desktop:

[Desktop Entry]
Name=Midnight Commander
MimeType=inode/directory
Exec=xterm -e mc %U
Type=Application
Categories=FileManager

Explanation: (1) The Exec takes up the job of invoking your terminal (in my case, XTerm) and then it runs mc in the terminal (that is what -e option is specifying). (2) Replacing %F with %U, URIs are correctly understood.

| improve this answer | |
  • Finally! What was missing from my mc.desktop is the %F in the Exec command. I had a working mc.desktop file with Terminal=true set by now. I can see now why MC would always open up in my home directory (however, not at the time I wrote the question) when GUI apps were asking MC to open specific directories. – David von Tamar Jan 27 at 12:52
  • 1
    I've upvoted this. But it would (by default) be better in ~/.local/share/applications/ than in /usr... don't you think? wiki.archlinux.org/index.php/Desktop_entries – Rusi Jan 27 at 14:15
  • @Rusi Agreed and corrected, thanks for pointing that out. – Quasímodo Jan 27 at 21:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.