Open ghost opened 6 years ago
Python has a list of browser commands that it will try to use to open a url, and when you set $BROWSER
or $RTV_BROWSER
it sticks your script at the top of that list. However, if your script fails to run for some reason, python will move on and try the next browser in the list which in your case is probably xdg-open
. I would double check that your script is executable, has a shebang, the path is correct, etc. There's no logging in rtv when you open $BROWSER
, so it makes sense you wouldn't see anything in the log file.
Here's an example that I tried using a dummy script. When I clicked on the links inside of RTV nothing happened (it didn't open my browser), and instead the link URLs were piped to a file.
> cat script.sh
#!/bin/bash
echo $1 >> browser_log.txt
> chmod +x script.sh
> env BROWSER="./script.sh" rtv
> cat browser_log.txt
http://i.imgur.com/OOFRJvr.gifv
https://i.reddituploads.com/58986555f545487c9d449bd5d9326528?fit=max&h=1536&w=1536&s=c15543d234ef9bbb27cb168b01afb87d
No problems with my script, I've been using it for a while with mailcap. Though I did copy-paste the dummy script and the commands you just posted for good measure, but rtv still opens it in qutebrowser and doesn't run the script at all. --log
still says $BROWSER
is ./script.sh
too. Is there something I'm missing?
Do you mind posting the rtv log on startup so I can see your environment?
Sure, here's the log of me launching rtv, then opening some random imgur link (which isn't actually visible here...).
linkhandler
is the name of the script I want to use, by the way.
2018-09-14 16:31:36,656:INFO:__main__.py:115:Starting new session, RTV v1.24.0
2018-09-14 16:31:36,656:INFO:__main__.py:116:/usr/bin/python, 3.7.0 (default, Jul 15 2018, 10:44:58)
[GCC 8.1.1 20180531]
2018-09-14 16:31:36,656:INFO:__main__.py:131:Environment: [('$DISPLAY', ':0'), ('$TERM', 'st-256color'), ('$LANG', 'en_US.UTF-8'), ('$XDG_CONFIG_HOME', '/home/neon/.config'), ('$XDG_DATA_HOME', None), ('$RTV_EDITOR', None), ('$RTV_URLVIEWER', None), ('$RTV_BROWSER', 'linkhandler'), ('$BROWSER', 'qutebrowser'), ('$RTV_PAGER', None), ('$PAGER', 'less'), ('$VISUAL', None), ('$EDITOR', 'vim')]
2018-09-14 16:31:36,656:INFO:__main__.py:155:RTV module path: /usr/lib/python3.7/site-packages/rtv/__main__.py
2018-09-14 16:31:36,657:INFO:__main__.py:160:Using packaged PRAW distribution, commit 1656ec224e574eed9cda4efcb497825d54b4d926
2018-09-14 16:31:37,649:DEBUG:connectionpool.py:823:Starting new HTTPS connection (1): api.reddit.com:443
2018-09-14 16:31:38,024:DEBUG:connectionpool.py:393:https://api.reddit.com:443 "POST /api/v1/access_token/ HTTP/1.1" 200 202
2018-09-14 16:31:38,029:DEBUG:connectionpool.py:823:Starting new HTTPS connection (1): oauth.reddit.com:443
2018-09-14 16:31:38,403:DEBUG:connectionpool.py:393:https://oauth.reddit.com:443 "GET /api/v1/me.json HTTP/1.1" 200 1956
2018-09-14 16:31:38,405:DEBUG:content.py:860:Rate limit: 1.0 used, 599.0 remaining, 502 reset
2018-09-14 16:31:40,238:DEBUG:connectionpool.py:393:https://oauth.reddit.com:443 "GET /.json?limit=1024 HTTP/1.1" 200 67529
2018-09-14 16:31:40,339:DEBUG:content.py:860:Rate limit: 2.0 used, 598.0 remaining, 502 reset
I'm having the same issue; I'm running Arch Linux, rtv 1.24.0 from the AUR.
I created the dummy script from above and rtv ignores it and opens the link in qutebrowser
. I can "fix" the issue by uninstalling xdg-utils
.
Same issue here. Fedora 29 / rtv 1.25.0
I am also having this issue on Arch Linux, rtv 1.25.1
. Here is my log:
2019-02-16 15:26:04,125:INFO:__main__.py:114:Starting new session, RTV v1.25.1
2019-02-16 15:26:04,125:INFO:__main__.py:115:/usr/bin/python, 3.7.2 (default, Jan 10 2019, 23:51:51)
[GCC 8.2.1 20181127]
2019-02-16 15:26:04,125:INFO:__main__.py:130:Environment: [('$DISPLAY', ':0'), ('$TERM', 'xterm-24bit'), ('$LANG', 'en_US.UTF-8'), ('$XDG_CONFIG_HOME', None), ('$XDG_DATA_HOME', None), ('$RTV_EDITOR', None), ('$RTV_URLVIEWER', None), ('$RTV_BROWSER', 'jaro'), ('$BROWSER', 'jaro'), ('$RTV_PAGER', None), ('$PAGER', None), ('$VISUAL', 'nvim'), ('$EDITOR', 'nvim')]
2019-02-16 15:26:04,125:INFO:__main__.py:154:RTV module path: /usr/lib/python3.7/site-packages/rtv/__main__.py
2019-02-16 15:26:04,125:INFO:__main__.py:159:Using packaged PRAW distribution, commit 1656ec224e574eed9cda4efcb497825d54b4d926
2019-02-16 15:26:04,462:DEBUG:connectionpool.py:813:Starting new HTTPS connection (1): api.reddit.com:443
2019-02-16 15:26:04,942:DEBUG:connectionpool.py:393:https://api.reddit.com:443 "POST /api/v1/access_token/ HTTP/1.1" 200 202
2019-02-16 15:26:04,947:DEBUG:connectionpool.py:813:Starting new HTTPS connection (1): oauth.reddit.com:443
2019-02-16 15:26:05,411:DEBUG:connectionpool.py:393:https://oauth.reddit.com:443 "GET /api/v1/me.json HTTP/1.1" 200 897
2019-02-16 15:26:05,412:DEBUG:content.py:929:Rate limit: 5.0 used, 595.0 remaining, 235 reset
2019-02-16 15:26:06,946:DEBUG:connectionpool.py:393:https://oauth.reddit.com:443 "GET /.json?limit=1024 HTTP/1.1" 200 77665
2019-02-16 15:26:07,143:DEBUG:content.py:929:Rate limit: 6.0 used, 594.0 remaining, 235 reset
I just opened rtv and hit enter on first link. It opens the link in qutebrowser
(which indicates that rtv
is using xdg-open
and not my script. I also tried the script that you provided.). I also tried setting enable_media
to true/false and it did not change anything.
Redirecting links trough mailcap to my script works as expected but this way I can only redirect media links, other links are still handled to xdg-open
.
Escalating issue from a question to a bug
I noticed this issue too when I tried rtv from pip
Tried it using firejail. No browser is launched.
exec_browser=$(mktemp --suffix=.sh)
chmod 755 "$exec_browser"
cat >"$exec_browser" <<EOF
#!/bin/bash
echo "$1" >> /tmp/browser_log.txt
EOF
firejail --net=tornet --dns="$mydns"\
--env=RTV_BROWSER="$exec_browser" --allow-debuggers strace -o "$strace_log" -f rtv --config "$fn_rtv_cfg"
the "$strace_log" shows:
5 stat("/tmp/tmp.RhjiERi9Jn.sh", {st_mode=S_IFREG|0755, st_size=44, ...}) = 0
5 access("/tmp/tmp.RhjiERi9Jn.sh", X_OK) = 0
5 stat("/tmp/tmp.RhjiERi9Jn.sh", {st_mode=S_IFREG|0755, st_size=44, ...}) = 0
and that's it. RTV just stats the file a couple times but does nothing else with it and does not even attempt to open or execute it.
I wrote a script that opens links into the programs I want that I'd like to use as a "browser", which is much more flexible compared to mailcap (I've tried using a mailcap with
application/*
,image/*
,audio/*
,video/*
andtext/*
set to simply pass all arguments to that same script, but I guess some website don't fit in any of the categories above for some weird reason and they just get forwarded to my browser).Anyway, setting RTV_BROWSER and/or BROWSER to
script.sh
and opening a link in rtv just opens it in my default browser (qutebrowser).rtv --log ...
confirms that they are indeed set to my script.enable_media
is set to False in rtv.cfg, and I also tried removing the config file, with no luck. Altough something I noticed is thatrtv --enable-media --log ...
outputsxdg-open <link>
when a link is opened, whereas leaving enable_media off doesn't output anything, which leads you to believe that it doesn't runxdg-open
, but my guess is that it's somehow ran anyway, since rtv alone wouldn't have any way of knowing my default browser with BROWSER set to another script.I've also tried using a "dummy" script that just creates a file when ran, but it didn't do anything when I opened the link with rtv, so my original script works fine, and rtv isn't both running the script AND opening my browser.
Arch Linux, rtv 1.24.0 from the AUR.