Incompatibility btw. ROX on Puppy and Calibre 3.39.1 ?

Please post any bugs you have found
Message
Author
clerk_gabel
Posts: 24
Joined: Wed 29 Aug 2018, 15:13
Location: norway

Incompatibility btw. ROX on Puppy and Calibre 3.39.1 ?

#1 Post by clerk_gabel »

Using Slacko 6.3.2 with ROX and Calibre 3.39.1 calls for external viewers for pdf, docx. doc etc. from within Calibre (otherwise working fine) is aborted, where errors like this are returned in a termina vindow

Code: Select all

 <?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope"><env:Body xmlns:rox="http://rox.sourceforge.net/SOAP/ROX-Filer"><env:Fault xmlns:rpc="http://www.w3.org/2001/12/soap-rpc" xmlns:env="http://www.w3.org/2001/12/soap-envelope"><faultcode>Failed</faultcode><faultstring>'/mnt/sda3/calibre-bibliotek/Ukendt/Darstellung%20der%20Aufnahme%20der%20ersten%20Juden%20in%20Hamburg%20(177)/Darstellung%20der%20Aufnahme%20der%20ersten%20Juden%20-%20Ukendt.doc' is not a valid URI</faultstring></env:Fault></env:Body></env:Envelope>
As Calibres internal viewer works fine for .epup but lags when opening .pdf I reported this bug / incompatibility with Rox to Calibre and received within an hour feed-back from the main developer Kovid Goyal who wrote:
"calibre uses Qt's openExternalUrl() function which IIRC on linux uses the xdg-open shell script. If it is not working, xdg-open on your system is broken, fix it and you will be fine."

the xdg-open on Slacko 6.3.2 is:

Code: Select all

   #!/bin/sh
#this script created by Jemimah. see: http://murga-linux.com/puppy/viewtopic.php?t=63400&start=150
#110115 xdg-open used to be a symlink to defaulthandler.
#!/bin/bash
case "$1" in 
        '') exit
                ;;
        *://*) exec rox -U "$1"
                ;;
        *@*.*) exec rox -U "mailto:${1}"
                ;;
        *) exec rox "$1"
                ;;
esac
I have tried deleting xdg-open and instead setting it as symlink from defaulthandler to no avail - any suggestions / comments /ideas for a workaround?

williams2
Posts: 337
Joined: Fri 14 Dec 2018, 22:18

#2 Post by williams2 »

Calibre is replacing all spaces in the filename with %20.

a quick workaround could be to replace:

Code: Select all

*) exec rox "$1"
with:

Code: Select all

exec rox "$(echo "$1"|sed "s/%20/ /g")"
in the file xdg-open. This might affect other programs that use xdg-open. Or not.

By the way, there is a bug in bionicpup64-7.9.7 xdg-open. The magnet line will never execute:

Code: Select all

*) exec rox "$1"
    ;;
magnet:*) exec transmission "$1"
because *) exec rox "$1" will execute first and never return.

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#3 Post by disciple »

calibre uses Qt's openExternalUrl() function which IIRC on linux uses the xdg-open shell script. If it is not working, xdg-open on your system is broken, fix it and you will be fine."
Puppy's xdg-open is different from the "standard" xdg-open found in most distros, so maybe that one would do things differently and work.
But it does look like Calibre is providing a mashup between a file path and a URI. Like Williams2 said, a file path shouldn't use %20. A URI should use the %20, but it should also be prefixed with file://
I suspect other more common filers (or whatever the standard xdg-open sends file paths to) are able to cope with a bastardised path/URI, but Rox simply isn't that tolerant.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

oldaolgeezer
Posts: 64
Joined: Sun 03 Dec 2006, 19:34

ROX and Calibre 3.39.1 external viewers for pdf, doc

#4 Post by oldaolgeezer »

I have an older calibre 3.33.1 on my xenialpup 7.5 - 32 bit, but:

I assume that you have pdf, docx. doc files already dragged into calibre
and you are clicking on the "Formats" line on the right side of the calibre screen after selecting one of the non ebook files mentioned above.

locating xdg-open:

find / -name *xdg-open* -print
/usr/bin/xdg-open <=== this is just a symbolic link to the file in the next line
/usr/local/bin/xdg-open

In DpupStretch: /usr/local/bin/xdg-open is:

case "$1" in
'') exit ;;
*://*) exec defaultbrowser "$1" ;;
*@*.*) exec rox -U "mailto:${1}" ;;
*) exec defaultfilemanager "$1" ;;
esac
===

the xdg-open on Slacko 6.3.2 (with no "magnet" line)
and xenialpup 7.5 - 32 bit: /usr/local/bin/xdg-open is:

#!/bin/bash
case "$1" in
'') exit
;;
*://*) exec rox -U "$1"
;;
*@*.*) exec rox -U "mailto:${1}"
;;
*) exec rox "$1"
;;
magnet:*) exec transmission "$1"
;;
esac

===

If you follow the case..esac settings:

Something with "//" in it is launched as an URL
Something with "@" in it is launched as an e-mail address
Anything else ("*") is processed through ROX's regular MIME
file-type database.

===

after saving a copy of /usr/local/bin/xdg-open, add one line
*://*) exec defaultbrowser "$1" ;;
to the file: /usr/local/bin/xdg-open
before the *://*) exec rox -U "$1" line so that the lines look like this:

case "$1" in
'') exit
;;
*://*) exec defaultbrowser "$1" ;;
*://*) exec rox -U "$1"
;;
*@*.*) exec rox -U "mailto:${1}"
;;
*) exec rox "$1"
;;
esac

===

This lets the "defaultbrowser" handle those non ebook calibre "files".

On my laptop, telling calibre to open a previously given to calibre .doc or .pdf file, my default browser, palemoon, displays a little window offering a choice of saving the file (which calibre already has a copy) but also offers to execute the defaultwordprocessor (for a .doc file) or qpdfview (for a .pdf file.)

williams2
Posts: 337
Joined: Fri 14 Dec 2018, 22:18

#5 Post by williams2 »

a file could have the characters %20 in the name. This might work better. Replace:

Code: Select all

*) exec rox "$1"
with:

Code: Select all

test -f "$1" && exec rox "$1"
exec rox "$(echo "$1"|sed "s/%20/ /g")"
If the file exists, it opens it with rox (which does the same thing that clicking the file would do.) If the file does not exist, it then tries changing %20s to spaces.

oldaolgeezer, the filename Calibre supplied does not seem to have the characters "://" in it, so I don't think this should work.

Code: Select all

*://*) exec defaultbrowser "$1" ;;
I think this should work - replace:

Code: Select all

*) exec rox "$1"
  ;;
with:

Code: Select all

test -f "$1" && exec rox "$1"
exec defaultbrowser "$1"
  ;;

oldaolgeezer
Posts: 64
Joined: Sun 03 Dec 2006, 19:34

Incompatibility btw. ROX on Puppy and Calibre 3.39.1

#6 Post by oldaolgeezer »

I did a little more testing, by dragging and dropping a test pdf and doc file
onto my calibre's desktop icon.

On my slacko-6.3.2-uefi, with the *://*) exec defaultbrowser "$1" ;; line
addition to /usr/local/bin/xdg-open, telling calibre to open the calibre
file called: "IRS f1040", the defaultbrowser, firefox,
was passed the string:

file:///mnt/home/Documents%20and%20Settings/Owner/Calbre_Library/SE_W_CAR_MP/2018%20Form%201040%20%28356%29/2018%20Form%201040%20-%20SE_W_CAR_MP.pdf

and firefox displayed the IRS form (with a space in its name.)

telling calibre to open the calibre file called: "Calibre test of doc file in Puppy slacko-6.3.2-uefi.doc", the defaultwordprocessor, abiword,
was passed the string:
file:///mnt/home/Documents%20and%20Settings/Owner/Calbre_Library/Unknown/Calibre%20test%20of%20doc%20file%20in%20Puppy%20slacko-6.3.2-uefi%20(357)/Calibre%20test%20of%20doc%20file%20in%20Puppy%20slacko-6%20-%20Unknown.doc
and abiword displays the Microsoft doc file (with spaces in its name.)

(I believe the word "Unknown" within the string was because calibre had no author's name.)

Notice that both strings start with "file:///" so that someone smarter than me
could craft a better fix to /usr/local/bin/xdg-open.

I had left myself a note, that in my slacko-6.3.2-uefi, when my calibre was first installed,
I also needed and wanted the "fix" described here: "Open the browser from Calibre's ebook-viewer application"
(otherwise you can not get high lighting and then right clicking for calibre's
dictionary and search to work within calibre's ebook-viewer application):
http://www.murga-linux.com/puppy/viewtopic.php?t=112879
Attachments
Screenshot of Calibre test of doc file.png
(32.53 KiB) Downloaded 239 times

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#7 Post by disciple »

How do you know Firefox is receiving a file:// and not adding it itself?
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

williams2
Posts: 337
Joined: Fri 14 Dec 2018, 22:18

#8 Post by williams2 »

The first thing I thought of was to put a line in xdg-open to show exactly what was being passed to xdg-open, like

Code: Select all

echo "$@" >> /tmp/xdg-open.log
but the rox error message in the first post showed the file name, without file://. But it MUST have :// in the name for oldaolgeezer's method to work. If I type

Code: Select all

rox -U file:///tmp/xerrs.log
the rox error message says
<faultstring>'/tmp/xerrs.log' is not a valid URI
even though file:// was part of the filename.

So Calibre must be passing a filename with file://, which is almost certainly a valid URI. The browser can handle the URI properly, but rox does not. It might be possible to fix the way rox handles the file:// protocol using xdg-mime and update-mime-database which configure the files in, I think, /usr/share/mime/.

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#9 Post by disciple »

Ok yes, you guys are dealing with a broken Puppy or puppies. That works perfectly in the version of Slacko I have here.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

williams2
Posts: 337
Joined: Fri 14 Dec 2018, 22:18

#10 Post by williams2 »

The symlink /etc/xdg/rox.sourceforge.net/URI/file doesn't seem to work. Don't know why, but it should be easy to fix. Maybe something in /etc/xdg/rox.sourceforge.net/MIME-types/.

oldaolgeezer
Posts: 64
Joined: Sun 03 Dec 2006, 19:34

Incompatibility btw. ROX on Puppy and Calibre 3.39.1

#11 Post by oldaolgeezer »

Hi williams2

The symlink supplies a missing "https" in /root/Choices/URI (not in /etc) in some puppy iso's
(the older one for just "http" has been in puppy for a long time):

ln -s /usr/local/bin/defaultbrowser /root/Choices/URI/https

Re: How do you know Firefox is receiving a file:// and not adding it itself?

You ask a good question, and I know very little about the workings of calibre and xdg-open.

But, I tried another simple test: I added yet another addition line in front of the new line
I previously suggested, so that my slacko-6.3.2-uefi /usr/local/bin/xdg-open looks like this:

case "$1" in
'') exit
;;
*://*) exec echo "$1" > /tmp/xyz ;;
*://*) exec defaultbrowser "$1" ;;
*://*) exec rox -U "$1"
;;
*@*.*) exec rox -U "mailto:${1}"
;;
*) exec rox "$1"
;;
esac

then I told calibre to open the calibre file called: "Calibre test of doc file in Puppy slacko-6.3.2-uefi.doc" and in /tmp/xyz there is this string:
file:///mnt/home/Documents%20and%20Settings/Owner/Calbre_Library/Unknown/Calibre%20test%20of%20doc%20file%20in%20Puppy%20slacko-6.3.2-uefi%20(357)/Calibre%20test%20of%20doc%20file%20in%20Puppy%20slacko-6%20-%20Unknown.doc

notice the word "file" colon followed by three slashes (more than just the colon and two slashes which were previously tested for.

For a second test, when I selected an ebook in calibre, and opened it (this executes the calibre ebook-viewer application
in a new window and then highlighted the word "Civilization" in that ebook,
and right clicked on search, the file: /tmp/xyz contained the string:
https://www.google.com/search?q=Civilization

notice the word "https" colon followed by two slashes (this is meant for a browser not ROX's MIME-Type file handling.)

(for these tests, I kept adding an additional line in /usr/local/bin/xdg-open
so it is easy for me to modify or remove the line(s) after the test.)

We have to remember to restore our /usr/local/bin/xdg-open after all these tests !

williams2
Posts: 337
Joined: Fri 14 Dec 2018, 22:18

#12 Post by williams2 »

The OP asked for a workaround. I think the attached file (gzipped, after downloading just click it to upzip it) should workaround your problem with Calbre. If it looks mostly like your xdg-open file, you can copy it to the right place in /usr/local/bin/. It's a good idea to backup the original file.

It might be a configuration problem, or it might be in the Rox source.

This is most of the file:

Code: Select all

#!/bin/bash
case "$1" in
        '') exit
                ;;
        file://*) exec defaultbrowser "$1"
                ;;
        magnet:*) exec transmission "$1"
                ;;
        *://*) exec rox -U "$1"
                ;;
        *@*.*) exec rox -U "mailto:${1}"
                ;;
        *) exec rox "$1"
                ;;
esac
It should open the file with the default browser, which can deal with URIs.

I'm running bionicpup64-7.9.7 (I know, not the latest version.)
Attachments
xdg-open.gz
(278 Bytes) Downloaded 290 times

williams2
Posts: 337
Joined: Fri 14 Dec 2018, 22:18

#13 Post by williams2 »

oldaolgeezer, thanks for your help.

My Puppy has https in /etc/xdg/rox.sourceforge.net/URI/. So this works:

rox -U https://www.goggle.com

but file:// doesn't work.

file:// is the protocol, /root/readme is a filename, so the URI would be:
file:///root/readme
which is why there are 3 /s. I think it needs to be an absolute path.

clerk_gabel
Posts: 24
Joined: Wed 29 Aug 2018, 15:13
Location: norway

#14 Post by clerk_gabel »

Thank you for replies. I have tested the suggestions except the by williams2 attached file (running out of time for today)
The "bug" is very minor as the Calibre add-on (Open With) will compensate, but doubleclicking on a thumb and seeing the MIME linked viewer pop up on top is nice.
If replacing in Slackos default xdg-open:

Code: Select all

*) exec rox "$1"
with
exec rox "$(echo "$1"|sed "s/%20/ /g")"
the terminal returns

Code: Select all

# calibre
/usr/local/bin/xdg-open: line 14: syntax error near unexpected token `rox'
/usr/local/bin/xdg-open: line 14: `exec rox "$(echo "$1"|sed "s/%20/ /g")"'
# 
If using the whole dpupstretch xdg-open

Code: Select all

case "$1" in
'') exit ;;
*://*) exec defaultbrowser "$1" ;;
*@*.*) exec rox -U "mailto:${1}" ;;
*) exec defaultfilemanager "$1" ;;
esac 
a Palemoon dialog box saying "You have chosen to open ...pdf" with options for picking an application or saving in a directory.
Canceling the dialog box returns

Code: Select all

# calibre
GLib-GIO-Message: Using the 'memory' GSettings backend.  Your settings will not be saved or shared with other applications.
# 
and clicking on OK without navigating to a specific application results in Evince displaying the pdf.
After closing Evince -> Palemoon -> Calibre the console messages was:

Code: Select all

# calibre
GLib-GIO-Message: Using the 'memory' GSettings backend.  Your settings will not be saved or shared with other applications.
GLib-GIO-Message: Using the 'memory' GSettings backend.  Your settings will not be saved or shared with other applications.
(evince:19492): GLib-GObject-WARNING **: gsignal.c:2593: instance `0x894c098' has no handler with id `1001'
(evince:19492): GLib-GObject-WARNING **: gsignal.c:2593: instance `0x894c098' has no handler with id `1002'
# 
Doc documents called my word processor as an unregistered application (demanding a serial) and txt files wad displayed in Palemoon.

If using the "magnet" xdg-open

Code: Select all

case "$1" in
'') exit
;;
*://*) exec rox -U "$1"
;;
*@*.*) exec rox -U "mailto:${1}"
;;
*) exec rox "$1"
;;
magnet:*) exec transmission "$1"
;;
esac 
the primary error was returned in the terminal, and if when using

Code: Select all

case "$1" in
'') exit
;;
*://*) exec defaultbrowser "$1" ;;
*://*) exec rox -U "$1"
;;
*@*.*) exec rox -U "mailto:${1}"
;;
*) exec rox "$1"
;;
esac 
behavior similar to dpupstretch with Palemoon dialog happend, with console output also very similar:

Code: Select all

# calibre                                                                 
GLib-GIO-Message: Using the 'memory' GSettings backend.  Your settings will not be saved or shared with other applications.
(evince:9177): GLib-GObject-WARNING **: gsignal.c:2593: instance `0x8810098' has no handler with id `1001'
(evince:9177): GLib-GObject-WARNING **: gsignal.c:2593: instance `0x8810098' has no handler with id `1002'
# 
Thank you for efforts.Williams2, it looks as if you are a long way in programming a new Calibre add-on where the Open With addon already exist (integrates in the right click menu and can be included in the toolbar). I will test the attached file when I am not so occupied.

williams2
Posts: 337
Joined: Fri 14 Dec 2018, 22:18

#15 Post by williams2 »

It says in xdg-open:
xdg-open used to be a symlink to defaulthandler
This:

Code: Select all

file://*) exec defaultbrowser "$1"
could be replaced with this:

Code: Select all

file://*) exec defaulthandler "$1"
Geany can use URIs, also libreoffice. qpdfview does not work with URIs.

clerk_gabel, yes it's a very minor bug. The sed line will definitely not work, it assumed there was not a first:// prefix.

All I have done is to put 1 line in xdg-open to workaround the problem so that Puppy will work the way it did before this (minor) bug.

clerk_gabel
Posts: 24
Joined: Wed 29 Aug 2018, 15:13
Location: norway

#16 Post by clerk_gabel »

ROX on this Slacko will open Evince for pdf, docx's with Textmaker18 and txt in geany
Using the by Williams2 provided and amended xdg-open:

Code: Select all

#!/bin/bash
case "$1" in
        '') exit
                ;;
        file://*) exec defaulthandler "$1"
                ;;
        magnet:*) exec transmission "$1"
                ;;
        *://*) exec rox -U "$1"
                ;;
        *@*.*) exec rox -U "mailto:${1}"
                ;;
        *) exec rox "$1"
                ;;
esac
the cosole reply:

Code: Select all

# calibre
Unable to detect a launcher for 'file:///mnt/sda3/calibre-bibliotek/Hans Jacob Zur-Eich/Africanische Reiszebeschreibung (9)/Africanische Reiszebeschreibung - Hans Jacob Zur-Eich.pdf'
# calibre
Unable to detect a launcher for 'file:///mnt/sda3/calibre-bibliotek/Alfonso Cassuto/Glyknoter 2 (146)/Glyknoter 2 - Alfonso Cassuto.docx'
# calibre
Unable to detect a launcher for 'file:///mnt/sda3/calibre-bibliotek/Ukendt/glyk (148)/glyk - Ukendt.txt'
# 
Again, thank you for efforts. My Puppy is great with many appreciated aplications installed including Calibre, so living with this minor flaw is not hard.Stones must have had a deep sense of the basic human condition when they sang "You can't always get what you want" :lol:

williams2
Posts: 337
Joined: Fri 14 Dec 2018, 22:18

#17 Post by williams2 »

I found why Rox is broken. This is /usr/local/bin/roxfiler:

Code: Select all

exec /usr/local/apps/ROX-Filer/AppRun "${@#*file://}"
It is cutting the prefix file:// from the beginning of the filename. Rox reports that it is not a valid URI because it is not a valid URI without the file:// prefix.

If

Code: Select all

"${@#*file://}"
is replaced with

Code: Select all

"$@"
Rox works properly with the -U option.

xdg-open can work properly whether roxfiler is modified or not, like this:

Code: Select all

#!/bin/sh
#this script created by Jemimah. see: http://murga-linux.com/puppy/viewtopic.php?t=63400&start=150
#110115 xdg-open used to be a symlink to defaulthandler.

case "$1" in
        '') exit
                ;;
        file://*) exec /usr/local/apps/ROX-Filer/AppRun -U "$1"
                ;;
        magnet:*) exec transmission "$1"
                ;;
        *://*) exec rox -U "$1"
                ;;
        *@*.*) exec rox -U "mailto:${1}"
                ;;
        *) exec rox "$1"
                ;;
esac
Last edited by williams2 on Thu 14 Feb 2019, 07:29, edited 1 time in total.

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#18 Post by disciple »

Except it isn't actually rox that needs modification :roll:
That is part of woof-ce; and a recent introduction by the looks of it: https://github.com/puppylinux-woof-CE/w ... al/bin/rox
I'll file a ticket or maybe a pull request, unless someone beats me to it.
I don't understand what they were dtrying to achieve - did they not know that rox is perfectly capable of handling URIs, with a switch specifically for that? Or were they just trying to avoid using the switch?
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

williams2
Posts: 337
Joined: Fri 14 Dec 2018, 22:18

#19 Post by williams2 »

Edit: I forgot the -U after AppRun.

Not sure why this was done, but it breaks rox's ability to handle file:// URIs.

Maybe something like this was intended in roxfiler:

Code: Select all

case "$1" in
        *://*) exec /usr/local/apps/ROX-Filer/AppRun -U "$@" ;;
esac
exec /usr/local/apps/ROX-Filer/AppRun "$@"
which will work if all the arguments are URIs (or all the arguments are not URIs.) I don't think rox works with mixed arguments anyway (both URIs and non-URIs as arguments)

Edit: Well, it will work if $1 is a filename as opposed to an option.

woodenshoe-wi
Posts: 109
Joined: Sat 29 Jul 2017, 03:16
Location: Wisconsin

#20 Post by woodenshoe-wi »

disciple wrote:That is part of woof-ce; and a recent introduction by the looks of it:
Yes and no, I did add it to woof-CE, but it came from the rox-filer petbuild. It was probably a quick and dirty way to let rox open URLs without having to specify -U

Expanding on williams2's idea, can anyone come up with a scenario where this breaks?

Code: Select all

#!/bin/bash

[[ $# == 0 ]] && exec /usr/local/apps/ROX-Filer/AppRun

declare -a args

while [[ $# != 0 ]]; do

  case "$1" in
    -U) # next arg is a URL
      args[${#args[*]}]='-U'
      args[${#args[*]}]="$2"
      shift
      ;;
    *://*) # this arg is a URL
      args[${#args[*]}]='-U'
      args[${#args[*]}]="$1"
      ;;
    *) # add it to the list
      args[${#args[*]}]="$1"
      ;;
  esac

  shift

done

exec /usr/local/apps/ROX-Filer/AppRun "${args[@]}"

Post Reply