Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 19 Sep 2019, 09:22
All times are UTC - 4
 Forum index » House Training » Bugs ( Submit bugs )
Incompatibility btw. ROX on Puppy and Calibre 3.39.1 ?
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 3 [36 Posts]   Goto page: Previous 1, 2, 3 Next
Author Message
clerk_gabel

Joined: 29 Aug 2018
Posts: 24
Location: norway

PostPosted: Tue 12 Feb 2019, 21:53    Post subject:  

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:
#!/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:
# 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" Laughing
Back to top
View user's profile Send private message 
williams2

Joined: 14 Dec 2018
Posts: 141

PostPosted: Thu 14 Feb 2019, 00:28    Post subject:  

I found why Rox is broken. This is /usr/local/bin/roxfiler:
Code:
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:
"${@#*file://}"
is replaced with
Code:
"$@"
Rox works properly with the -U option.

xdg-open can work properly whether roxfiler is modified or not, like this:
Code:
#!/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, 03:29; edited 1 time in total
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6967
Location: Auckland, New Zealand

PostPosted: Thu 14 Feb 2019, 01:16    Post subject:  

Except it isn't actually rox that needs modification Rolling Eyes
That is part of woof-ce; and a recent introduction by the looks of it: https://github.com/puppylinux-woof-CE/woof-CE/blob/master/woof-code/rootfs-packages/rox_config/usr/local/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
Back to top
View user's profile Send private message 
williams2

Joined: 14 Dec 2018
Posts: 141

PostPosted: Thu 14 Feb 2019, 03:44    Post subject:  

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:
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.
Back to top
View user's profile Send private message 
woodenshoe-wi

Joined: 28 Jul 2017
Posts: 104
Location: Wisconsin

PostPosted: Fri 15 Feb 2019, 20:18    Post subject:  

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:
#!/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[@]}"
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6967
Location: Auckland, New Zealand

PostPosted: Sat 16 Feb 2019, 01:02    Post subject:  

I'm a bit confused now about whether we're talking about /usr/local/bin/rox, or xdg-open.

This is the only problem that springs to mind (I have assumed your script is /usr/local/bin/rox):
Code:
#  pwd
/tmp
#  mkdir file:
#  touch file:/a.txt
#  rox file:/a.txt
#  rox file:///a.txt

The last line fails with your script of course, but would otherwise be perfectly valid and work.

I really think you should keep all of that complication (not to mention the spawning of bash) out of "rox" - consolidate it into xdg-open.

_________________
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
Back to top
View user's profile Send private message 
woodenshoe-wi

Joined: 28 Jul 2017
Posts: 104
Location: Wisconsin

PostPosted: Sat 16 Feb 2019, 02:07    Post subject:  

Yes, it was an alternative /usr/local/bin/rox script.

One way or the other the current rox script needs to be fixed.

I was not the one who originally wrote the rox script, so I don't know what problem they were trying to solve with the original "${@#*file://}" hack.

It was my understanding that the reason that http:// URLs start with two slashes and file:/// URLs start with three slashes is that URLs are always absolute paths. That would mean that the example URL that didn't work would be interpreted as a valid URL to a non existent file, file:// /a.txt

If you wanted an actual URL to the file it would be file:///tmp/file%3A/a.txt

According to Wikipedia, valid file URLs include file:/path, so the case statement should probably read file:/*) That would catch the previous line too though.

About using bash, the only way I could figure out how to handle ordinary file names with spaces in them was to use an array. If the functionality of automatically opening URLs without having to specify -U is not needed, I would agree that the simpler the better.
Back to top
View user's profile Send private message 
williams2

Joined: 14 Dec 2018
Posts: 141

PostPosted: Sat 16 Feb 2019, 02:25    Post subject:  

I'm running bionicpup64-7.9.7

The original problem was that Calibre, a book reading program, was not opening the book when clicked.

Calibre passes the filename as a URI to xdg-open. The line in xdg-open is:
Code:
*://*) exec rox -U "$1"

rox just executes /usr/local/bin/roxfiler.
Code:
exec roxfiler "$@"

This is in roxfiler:
Code:
exec /usr/local/apps/ROX-Filer/AppRun "${@#*file://}"


The filename passed by Calibre to xdg-open would be something like file:///root/book.txt.
xdg-open would:
Code:
exec rox -U  file:///root/book.txt

roxfile would cut file:// from the filename then:
Code:
exec /usr/local/apps/ROX-Filer/AppRun -U /root/book.txt

The -U comes from xdg-open.

Assume roxfiler is not altering the filename. Then:
This works: rox /root/foo\ bar.txt
This works: rox -U file:///root/foo%20bar.txt
This fails: rox file:///root/foo%20bar.txt
This fails: rox -U /root/foo%20bar.txt
This fails: rox /root/foo%20bar.txt

That is, altering the filename in roxfiler does not seem to work.

If you put this in xdg-open:
Code:
file://*) exec /usr/local/apps/ROX-Filer/AppRun -U "$1"

it bypasses roxfiler, and passes -U file:///root/book.txt to AppRun, which fixes the problem with Calibre.

roxfiler still should not mangle the filename, because it does not seem to work the way it was intended. Rox seems to need -U with a URI and rox seems to need no -U for a non-URI name.

I don't think you can mix URIs and non-URIs as arguments to rox. That was what roxfiler was trying to do, but it seems not to work.
Back to top
View user's profile Send private message 
williams2

Joined: 14 Dec 2018
Posts: 141

PostPosted: Sat 16 Feb 2019, 02:29    Post subject:  

By the way, the xdg docs suggest that although
file:/root/foo%20bar.txt
is not valid, it should be supported by software because such names are often used anyway.
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6967
Location: Auckland, New Zealand

PostPosted: Sat 16 Feb 2019, 02:35    Post subject:  

woodenshoe-wi wrote:
Yes, it was an alternative /usr/local/bin/rox script.

One way or the other the current rox script needs to be fixed.

I was not the one who originally wrote the rox script, so I don't know what problem they were trying to solve with the original "${@#*file://}" hack.

It was my understanding that the reason that http:// URLs start with two slashes and file:/// URLs start with three slashes is that URLs are always absolute paths. That would mean that the example URL that didn't work would be interpreted as a valid URL to a non existent file, file:// /a.txt

Please look at the commands I ran again. The whole point is that it is not a URI, it just looks like one. It is a file path.

And the main point I was trying to make is that if xdg-open is detecting file paths vs uris then there should be no need to do the same thing in a "rox" or "roxfiler" or whatever it happens to be called. The author of the broken script quite likely didn't know (or forgot) about xdg-open, so they essentially tried to reimplement it instead of looking to see if there was already a solution.

_________________
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6967
Location: Auckland, New Zealand

PostPosted: Sat 16 Feb 2019, 02:55    Post subject:  

woodenshoe-wi wrote:
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.

Wherever that petbuild came from, again I think it is relatively recent, as my version of Slacko doesn't have it.

_________________
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6967
Location: Auckland, New Zealand

PostPosted: Sat 16 Feb 2019, 05:43    Post subject:  

While we're at it, there's another issue with using xdg-open.
It seems that I wasn't completely right when I said rox -U handles uris perfectly - these guys have found that it drops anything after a # http://murga-linux.com/puppy/viewtopic.php?t=110057, concluding that xdg-open should use defaultbrowser instead. But for file:/// uris that would only be desirable when they are for html files. Unless this is an issue with the configuration in Puppy (e.g. /etc/xdg/rox.sourceforge.net/URI) I think it is a bug in rox itself, and should be fixed there.

_________________
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
Back to top
View user's profile Send private message 
williams2

Joined: 14 Dec 2018
Posts: 141

PostPosted: Sat 16 Feb 2019, 18:36    Post subject:  

Code:
# ls /root/fo*
'/root/fo#o bar.txt'  '/root/foo bar.txt'
# xdg-open file:///root/fo#o%20bar.txt
# xdg-open "file:///root/fo#o%20bar.txt"
# xdg-open 'file:///root/fo#o%20bar.txt'
#


These each open geany on my Pup, no error messages.
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6967
Location: Auckland, New Zealand

PostPosted: Sun 17 Feb 2019, 05:41    Post subject:  

Yeah, that works for me, too. So the issue is specifically with what they called "anchor links".
They were talking about file:///some/local/file.html#anchor, which I haven't tried.
But I tried links to specific posts on this forum, which didn't work either, so it affects both file and http uris.
Try e.g. http://murga-linux.com/puppy/viewtopic.php?p=1018477#1018477 - defaultbrowser will load it correctly, but rox -U won't.

_________________
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
Back to top
View user's profile Send private message 
williams2

Joined: 14 Dec 2018
Posts: 141

PostPosted: Sun 17 Feb 2019, 14:42    Post subject:  

That link works on my Pup, bionicpup64-7.9.7.
Code:
# rox -U http://murga-linux.com/puppy/viewtopic.php?p=1018477#1018477
# /usr/local/apps/ROX-Filer/AppRun -U http://murga-linux.com/puppy/viewtopic.php?p=1018477#1018477
# defaultbrowser http://murga-linux.com/puppy/viewtopic.php?p=1018477#1018477
# xdg-open http://murga-linux.com/puppy/viewtopic.php?p=1018477#1018477


All of these work, pops up my "Starting Firefox" splash, opens a new tab in firefox (65.0.1 64 bit.) It displays the same page I see if I paste the link in the Firefox address bar.

My /usr/local/bin/roxfiler:
Code:
#!/bin/sh
exec /usr/local/apps/ROX-Filer/AppRun "$@"
exec /usr/local/apps/ROX-Filer/AppRun "${@#*file://}"

My /usr/bin/xdg-open:
Code:
#!/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


By the way, there are programs already written to convert URI to standard file system names, e.g.
https://rosettacode.org/wiki/URL_decoding
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 2 of 3 [36 Posts]   Goto page: Previous 1, 2, 3 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Bugs ( Submit bugs )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0852s ][ Queries: 12 (0.0244s) ][ GZIP on ]