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.

4
  • I have no used debian in some time, but have you read this article?
    – number9
    Commented Jan 7, 2019 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. Commented Jan 7, 2019 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
    Commented Jan 7, 2019 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. Commented Jan 7, 2019 at 4:07

1 Answer 1

3

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.

1
  • Only adding this mc.desktop to ./local/share/applications/ did not work for me, resulted in errors about /usr/bin/xdg-open: line 811: : command not found /usr/bin/xdg-open: line 881: x-www-browser: command not found ATTENTION: default value of option mesa_glthread overridden by environment. Missing chrome or resource URL: resource://gre/modules/UpdateListener.jsm -----> Fixed by adding mc.desktop to /usr/share/applications/. Commented Jun 21, 2022 at 13:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .