SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2015-09-07 13:13:04

ghorvath
#! Member
Registered: 2015-05-20
Posts: 53

[Solved] Midnight Commander should open files in background

I am using Midnight commander (mc) to have a 2-panel file manager. I can open any file by simply pressing ENTER on them. However, when I do this, then Midnight Commander shows the shell output, and I cannot use mc anymore, until I close the program which opened the file. E.g. I open a doc file, then it starts libreoffice, and I cannot use mc for browsing until libreoffice is not closed.

However if libreoffice is already running, then I can open any doc file and will get mc back and can open new doc files with it. I asked around and some people told me that this is the default behaviour of their Midnight Commander (even for starting the program they get mc back for browsing). I even managed to get my hands on an ini file they use, but using that file as configuration file, it still did not let me get back to mc when I opened a first doc file and libreoffice started running.
(This other guy is also running debian jessie (with xfce, not bl), and has the same version of mc as I use: 3:4.8.13-3)

Does anyone know why this is happening?

Last edited by ghorvath (2015-09-11 15:58:36)

Offline

Help fund CrunchBang, donate to the project!

#2 2015-09-07 16:04:53

ostrołęk
CB Member
Registered: 2015-08-13
Posts: 110

Re: [Solved] Midnight Commander should open files in background

That is the standard behaviour of Midnight Commander, as it works only in a terminal. It cannot open .doc files in it, but would open the file in the relevant writer app, in your case Libreoffice Writer. MC works in the old fashioned way, but it is quite reliable. If you want simple gui dual pane file managers, you might like to read this, https://www.linux.com/learn/tutorials/7 … e-managers

Offline

#3 2015-09-07 16:42:28

brontosaurusrex
#! Red Menace
Registered: 2012-06-15
Posts: 1,643

Re: [Solved] Midnight Commander should open files in background

Offline

#4 2015-09-09 07:07:43

ghorvath
#! Member
Registered: 2015-05-20
Posts: 53

Re: [Solved] Midnight Commander should open files in background

@ostrolk:
I am sorry, but I do not understand. Is the default behaviour to get back mc when the appropriate opening application is already running but not get back mc, when the application is not yet running? Also: how come in vanilla xfce it works as you get back mc no matter if the opening application was running before or not. In fact, I was told that the opening application will not even close, no matter whether you shut down mc, or even the terminal you opened mc from. Thus, it most start the opening applications with nohup or something similar. Or maybe it just sends it to the basic X file manager to open it (whatever that is, if it is installed), and that will start opening the file with the appropriate application.

@ brontosaurusrex:
I found this page, as well, but that is a 2 years old thread. I would expect by now that this is already coded into mc, as I would expect the default behaviour to start the opening application such that you get back mc for further browsing. It would make more sense to me that somehow mc is not properly integrated into the X, maybe some package is missing from the basic bl netinstall?

UPDATE:
ps -f shows that mc opens the files with xdg-open. So one needs to set this up properly, somehow.

UPDATE 2: Ok, now I have solved this, using

https://wiki.archlinux.org/index.php/Mi … ning_files

Just create a file ~/bin/xdg-open-null containing

#!/bin/bash
nohup xdg-open "$@" >/dev/null &

and then before starting mc run

export MC_XDG_OPEN=~/bin/xdg-open-null

in the terminal.

UPDATE 3: This is good when one wants to open local files. Does not work when opening files via sftp. sad

Last edited by ghorvath (2015-09-09 11:00:50)

Offline

#5 2015-09-09 18:30:30

brontosaurusrex
#! Red Menace
Registered: 2012-06-15
Posts: 1,643

Re: [Solved] Midnight Commander should open files in background

It appears that selecting 'commands/Edit extension file' and adding '&' to 'open' lines (and probably the dev/null part as well) might be a path worth investigating.

Last edited by brontosaurusrex (2015-09-09 18:31:17)

Offline

#6 2015-09-10 16:52:04

ghorvath
#! Member
Registered: 2015-05-20
Posts: 53

Re: [Solved] Midnight Commander should open files in background

brontosaurusrex wrote:

It appears that selecting 'commands/Edit extension file' and adding '&' to 'open' lines (and probably the dev/null part as well) might be a path worth investigating.

I tried them, and none of them worked when I try to open a file which is reachable by sftp. It only works locally. I basically tried all possibilities in changing mc.ext and the particular .sh file in /usr/lib/mv/ext.d/

In fact, for locally, there is a much simpler solution by the answer from

http://unix.stackexchange.com/questions … -mime-type

All one needs to do is start mc in the following way:

export DE=xfce && mc

This basically says to open-xdg that the desktop environment is xfce, and it will then open everything with exo-open. Everything works perfectly as long as you open files locally. But when you try to open a file from an sftp-reachable place, then it does not work. What it should do is copy the file to /tmp under a different name, and then open the file in the /tmp directory. This works perfectly when one does not set the DE variable (but then you do not get back mc until you do not close the file). But somehow, if the variable DE is set, then the file is not copied to /tmp, but the appropriate application  is still launched with the appropriate filename in /tmp (and signals an error that the file is not in /tmp). It is just that the file has not been copied over to /tmp (in fact, I checked with inotifywait that /tmp is not touched at all).

So now I want to figure out why xdg-open does not copy over the file to /tmp when DE variable is set.

Offline

#7 2015-09-10 21:24:23

brontosaurusrex
#! Red Menace
Registered: 2012-06-15
Posts: 1,643

Re: [Solved] Midnight Commander should open files in background

@ghorvath: I see, quite an effort so far.

Offline

#8 2015-09-10 21:39:43

twoion
Emerald Caffeine
From: 星界
Registered: 2012-05-11
Posts: 1,648

Re: [Solved] Midnight Commander should open files in background

FYI, since this concerns the general behaviour of xdg-open, we are tracking this issue now here: https://github.com/BunsenLabs/bunsen-configs/issues/30.


Tannhäuser ~ {www,pkg,ddl}.bunsenlabs.org/{gitlog,repoidx}

Offline

#9 2015-09-11 12:20:33

ghorvath
#! Member
Registered: 2015-05-20
Posts: 53

Re: [Solved] Midnight Commander should open files in background

If anyone is interested, I have found a workaround. Mount the necessary directory of your sftp server with sshfs to somewhere locally, and then you can browse it in mc as if it were a local directory, and mc would behave (provided you start with defining variable DE) as you would expect. It is still interesting, though, why setting variable DE does not work always in Bunsenlabs without this hack.

How can I mark this thread solved?

Edit: Ok, in the end I have found the reason why it was not always working. I was using sometimes sftp on servers which are only ssh-servers but not sftp servers. And then it failed. However, when I used a simple shell connection to these servers, then everything really works as intended (provided one defines the DE variable before starting mc).

That is, the solution: start mc with

export DE=xfce && mc

(you might as well put a line into ~/.bash_aliases) and then use shell connections instead of sftp connections whenever possible. Then (as far as I can tell) you can open files by pressing ENTER and you always get mc back, as well. The workaround is not needed anymore, but it might be nice to have anyway.

Last edited by ghorvath (2015-09-13 07:26:00)

Offline

#10 2015-09-11 13:12:45

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: [Solved] Midnight Commander should open files in background

Edit your first post here and add [Solved] to the subject.


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat

Debian Logo