LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 09-27-2018, 03:32 PM   #1
andrixnet
Member
 
Registered: Oct 2012
Location: Romania
Distribution: Slackware
Posts: 167

Rep: Reputation: Disabled
Exclamation mc not opening html files ? (black screen)


I am not sure when this started to happen, but in recent monhts, and after some updates, at least more recent then Jul 11th.

It happens on Slack-14.2 with all updates to date.

Whenever I am in a console (via SSH, not X) and running mc, I press ENTER (open action) on a .html file, I get a black screen.
I press Ctrl-C, I get back to mc.

Previous, and expected behaviour, is, upon pressing ENTER, the file to be shown by links program.

I have tested and confirmed the problem on both distros, with all updates to date.
I have tested and seen the correct behaviour on a 14.1 system with updates to date.
I don't have a 14.2 installation with older (or no) updates available at this time.

All tested systems are full slackware installations.

Last edited by andrixnet; 09-27-2018 at 03:36 PM.
 
Old 09-27-2018, 03:51 PM   #2
abga
Senior Member
 
Registered: Jul 2017
Location: EU
Distribution: Slackware
Posts: 1,634

Rep: Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929
Can confirm this, but I never pressed Enter on a file in mc, always used F3 (view) / F4 (edit) (which are working fine).
 
Old 09-27-2018, 05:33 PM   #3
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
I'm not sure why the default would have changed, but you could change the handler for html in Command -> Edit extension file.
 
Old 09-27-2018, 06:38 PM   #4
abga
Senior Member
 
Registered: Jul 2017
Location: EU
Distribution: Slackware
Posts: 1,634

Rep: Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929
Actually there looks to be something broken in:
/usr/libexec/mc/ext.d/web.sh
script which handles the open/view of html files, by using either konqueror or lynx, which is called by mc from its extension conf file:
/etc/mc/mc.ext

I tried to debug web.sh but failed so far to see lynx launched.

P.S. References:
https://github.com/MidnightCommander...xt.d/web.sh.in
https://github.com/MidnightCommander...misc/mc.ext.in
The introduction of ext.d :
https://midnight-commander.org/ticket/2965

Last edited by abga; 09-27-2018 at 06:53 PM. Reason: P.S.
 
Old 09-27-2018, 07:29 PM   #5
abga
Senior Member
 
Registered: Jul 2017
Location: EU
Distribution: Slackware
Posts: 1,634

Rep: Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929
Some progress. I commented out in /usr/libexec/mc/ext.d/web.sh:
Code:
#[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
and now mc is opening html files by using links (elinks is not provided by Slackware, but available on Slackbuilds).

Looking to get lynx opening html files, I commented the following out:
Code:
#in -> do_view_action()
#        links -dump "${MC_EXT_FILENAME}" 2>/dev/null || \
#            w3m -dump "${MC_EXT_FILENAME}" 2>/dev/null || \
# in -> do_open_action()
#            elinks "${MC_EXT_FILENAME}" || \
#                links "${MC_EXT_FILENAME}" || \
xdg-open looks to be the issue and the solution might come from freedesktop.org. I wish I could help further, but my patience and interest ends with "freedesktop.org", sorry.
https://www.freedesktop.org/wiki/Software/xdg-utils/
 
Old 09-27-2018, 08:46 PM   #6
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
To avoid modifying /usr/libexec/mc/ext.d/web.sh, you can also just modify ~/.config/mc/mc.ext as so:

Code:
# html                                                                          
regex/i/\.html?$                                                                
  #Open=/usr/libexec/mc/ext.d/web.sh open html                                  
  Open=links %f                                                                 
  View=%view{ascii} /usr/libexec/mc/ext.d/web.sh view html
But yes, by default it will try to use xdg-open to open the file. I tried using xdg-mime to change the default for text/html, but it can be tricky to get it to work. The environment variable $BROWSER seems to override the default, and that worked for me to get it to open html files with Chromium instead of Konqueror, but that approach didn't work when I set BROWSER=links.

Last edited by montagdude; 09-27-2018 at 08:49 PM.
 
Old 09-27-2018, 08:55 PM   #7
abga
Senior Member
 
Registered: Jul 2017
Location: EU
Distribution: Slackware
Posts: 1,634

Rep: Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929
Just confirming my previous point, lack of patience, there are apparently two solutions, either disable the use of xdg-open (as I did in my previous post) or make some mime.types generally available for xdg-open:
http://midnight-commander-user-discu...td7574708.html
https://midnight-commander.org/ticket/2118

Like in the ticket above, I'm also asking myself what has xdg-open to do with a console based (ncurses) file manager.
 
Old 09-27-2018, 11:18 PM   #8
abga
Senior Member
 
Registered: Jul 2017
Location: EU
Distribution: Slackware
Posts: 1,634

Rep: Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929
Another general (system wide) way to get rid of the xdg_open for mc is to define an alias for it, like:
Code:
alias mc='MC_XDG_OPEN=false mc'
But then, there is already a wrapper for mc, maybe better modify it instead:
/usr/share/mc/bin/mc-wrapper.sh
Code:
/usr/bin/mc -P "$MC_PWD_FILE" "$@"
#to
MC_XDG_OPEN=false /usr/bin/mc -P "$MC_PWD_FILE" "$@"
And then at the end, optional:
Code:
unset MC_XDG_OPEN
P.S. Address the /usr/share/mc/bin/mc-wrapper.csh too.

Last edited by abga; 09-27-2018 at 11:38 PM. Reason: unset MC_XDG_OPEN + P.S.
 
Old 09-28-2018, 01:34 AM   #9
andrixnet
Member
 
Registered: Oct 2012
Location: Romania
Distribution: Slackware
Posts: 167

Original Poster
Rep: Reputation: Disabled
Wink

Thank you very much for the feedback.
I'll apply the fix.
 
Old 09-28-2018, 01:41 PM   #10
abga
Senior Member
 
Registered: Jul 2017
Location: EU
Distribution: Slackware
Posts: 1,634

Rep: Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929
These /usr/share/mc/bin/mc-wrapper.sh & /usr/share/mc/bin/mc-wrapper.csh fixes should maybe make their way upstream. If you're happy with the results, maybe write a post in the Requests for -current (14.2-->15.0) thread about this.
 
Old 09-28-2018, 02:05 PM   #11
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
Quote:
Originally Posted by abga View Post
These /usr/share/mc/bin/mc-wrapper.sh & /usr/share/mc/bin/mc-wrapper.csh fixes should maybe make their way upstream. If you're happy with the results, maybe write a post in the Requests for -current (14.2-->15.0) thread about this.
What about the people who want to use xdg-open? I don't get why upstream would accept a patch that disables the default behavior they purposely implemented.

Last edited by montagdude; 09-28-2018 at 02:07 PM.
 
Old 09-28-2018, 02:39 PM   #12
abga
Senior Member
 
Registered: Jul 2017
Location: EU
Distribution: Slackware
Posts: 1,634

Rep: Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929
Quote:
Originally Posted by montagdude View Post
What about the people who want to use xdg-open? I don't get why upstream would accept a patch that disables the default behavior they purposely implemented.
This is only about Midnight Commander (mc). Does xdg-open in the mc handler work? Isn't it why this thread was started in the first place? Out of the links I presented above, I learned that you either provide xdg-open with a mime.types or disable its usage.
 
Old 09-28-2018, 03:11 PM   #13
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
Quote:
Originally Posted by abga View Post
This is only about Midnight Commander (mc). Does xdg-open in the mc handler work? Isn't it why this thread was started in the first place? Out of the links I presented above, I learned that you either provide xdg-open with a mime.types or disable its usage.
Yeah, it works. I mean it successfully runs xdg-open on the file and opens it with the same application that would be used if you manually ran xdg-open file yourself from the command line. Getting xdg-open to use the application you really want is a different story, but that's not mc's concern.
 
Old 09-28-2018, 05:37 PM   #14
abga
Senior Member
 
Registered: Jul 2017
Location: EU
Distribution: Slackware
Posts: 1,634

Rep: Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929
I'm sorry, I cannot follow you, xdg-open doesn't work here with mc in both Slackware 14.2 and -current.
If I press Enter on a html file I get a blank screen, as originally reported by andrixnet, and this is what mc is doing:
Code:
               \_ /usr/bin/mc -P /tmp/mc-root/mc.pwd.3192
                   \_ bash -rcfile .bashrc
                   \_ /bin/sh /tmp/mc-root/mcextL8KXPZ
                       \_ /bin/sh /usr/libexec/mc/ext.d/web.sh open html
                           \_ /bin/sh /usr/bin/xdg-open /test/test.html
                               \_ links /test/test.html
It works if I press F3 (view), but in this case mc is not calling the /usr/libexec/mc/ext.d/web.sh handler:
Code:
               \_ /usr/bin/mc -P /tmp/mc-root/mc.pwd.3192
                   \_ bash -rcfile .bashrc
                   \_ [sh] <defunct>
In post #4 I was still investigating why I get a blank screen when I press Enter on a html file and considered that links might be faulty, looked after getting the html file opened in lynx instead. Only in post #5 I found out that xdg-open is the bugger.

If I modify the mc wrapper /usr/share/mc/bin/mc-wrapper.sh as described in post #8, then by pressing Enter on a html file I get it opened in links. Note that xdg-open si not launched anymore:
Code:
               \_ /usr/bin/mc -P /tmp/mc-root/mc.pwd.3192
                   \_ bash -rcfile .bashrc
                   \_ /bin/sh /tmp/mc-root/mcextS6KZPZ
                       \_ /bin/sh /usr/libexec/mc/ext.d/web.sh open html
                           \_ /bin/sh /usr/libexec/mc/ext.d/web.sh open html
                               \_ links /test/test.html
For resolving the reported problem you could only modify the handler /usr/libexec/mc/ext.d/web.sh, as described in post #5, but it looks like all the handlers are making use of xdg-open and this might cause issues with other document types too. Modifying the general /usr/share/mc/bin/mc-wrapper.sh is therefore a better solution.
Code:
/usr/libexec/mc/ext.d# grep -e xdg-open *
archive.sh:[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
doc.sh:[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
image.sh:[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
misc.sh:[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
package.sh:[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
sound.sh:[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
text.sh:[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
video.sh:[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
web.sh:[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
As described here in these links, xdg-open hangs because it cannot get a mime.types file, thus xdg-open is not properly integrated, and you either provide one (have no clue how to do that without interfering with other apps ... and also no patience with freedesktop.org stuff (stated before)) or you disable the xdg-open usage for Midnight Commander for good:
http://midnight-commander-user-discu...td7574708.html
https://midnight-commander.org/ticket/2118

Nevertheless, I personally don't really care about this issue with mc because in my limited use of it I only press Enter when browsing/changing folders, using F3/F4 when viewing/editing files. Pressing Enter on files can be dangerous, especially on laggy remote connections, where you could mistakenly execute something / script.

Last edited by abga; 09-28-2018 at 05:40 PM. Reason: typo
 
Old 09-28-2018, 05:45 PM   #15
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
Well, I don't know then. It works for me, possibly because I already have the necessary mime.types file on my system. I don't think that disabling xdg-open completely is the right fix. Maybe fora user who doesn't want to bother with it, but not for upstream. If they did want to do away with xdg-open, the right way to do it would be to remove it from the libexec scripts.

Last edited by montagdude; 09-28-2018 at 05:52 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Screen goes black on opening Dash on Ubuntu 17.04 vedk Linux - Laptop and Netbook 2 09-14-2017 09:01 PM
Acer A0A 110 has a black screen during boot up along with a black cursor sw3etpinay Linux - Newbie 23 12-29-2010 11:05 AM
Ubuntu 10.04 Lucid Lynx goes to black screen when opening Myspace DWXVI Linux - Newbie 5 05-16-2010 09:38 AM
Application tab gone. Where is Trash? Opening .HTML files Margaret Lowder Linux - Software 4 08-25-2008 03:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration