firecat53 / urlscan

Mutt and terminal url selector (similar to urlview)
GNU General Public License v2.0
211 stars 36 forks source link

Set BROWSER to xdg-open by default #1

Closed xuhdev closed 9 years ago

xuhdev commented 9 years ago

Sometimes people just want to use the default browser. It's relunctant to set BROWSER variable.

firecat53 commented 9 years ago

This note is primarily for people who may not use a Desktop Environment such as Gnome or KDE that automatically set the BROWSER variable for you. If you use a Desktop Environment, you don't need to set the variable. The default browser will be used automatically. Most standalone Window Managers (openbox, awesome, i3, etc.) don't take care of this detail for you.

Scott

xuhdev commented 9 years ago

Here's the error I got when BROWSER not set:

Traceback (most recent call last):
  File "/usr/bin/urlscan", line 112, in <module>
    main(msg)
  File "/usr/bin/urlscan", line 94, in main
    ui.main()
  File "/usr/lib/python3.4/site-packages/urlscan/urlchoose.py", line 131, in main
    return self.ui.run_wrapper(self.run)
  File "/usr/lib/python3.4/site-packages/urwid/curses_display.py", line 164, in run_wrapper
    return fn()
  File "/usr/lib/python3.4/site-packages/urlscan/urlchoose.py", line 157, in run
    self.top.keypress(size, k)
  File "/usr/lib/python3.4/site-packages/urwid/container.py", line 1124, in keypress
    return self.body.keypress( (maxcol, remaining), key )
  File "/usr/lib/python3.4/site-packages/urwid/listbox.py", line 985, in keypress
    key = focus_widget.keypress((maxcol,),key)
  File "/usr/lib/python3.4/site-packages/urwid/wimp.py", line 535, in keypress
    self._emit('click')
  File "/usr/lib/python3.4/site-packages/urwid/widget.py", line 463, in _emit
    signals.emit_signal(self, name, self, *args)
  File "/usr/lib/python3.4/site-packages/urwid/signals.py", line 264, in emit
    result |= self._call_callback(callback, user_arg, user_args, args)
  File "/usr/lib/python3.4/site-packages/urwid/signals.py", line 294, in _call_callback
    return bool(callback(*args_to_pass))
  File "/usr/lib/python3.4/site-packages/urlscan/urlchoose.py", line 27, in <lambda>
    return lambda *args: browser.browseto(url, background)
  File "/usr/lib/python3.4/site-packages/urlscan/browser.py", line 29, in browseto
    cmd([os.environ["BROWSER"], url])
  File "/usr/lib/python3.4/os.py", line 633, in __getitem__
    raise KeyError(key) from None
KeyError: 'BROWSER'
Press any key to continue...

I think the original version works because it is on Debian and has sentinel-www-browser, but on Arch there is nothing like this.

firecat53 commented 9 years ago

Ah, I didn't realize you actually had an error. I'll look into it.

firecat53 commented 9 years ago

Can you please checkout the 'browser' branch and test it for me?

Thanks! Scott

xuhdev commented 9 years ago

Yes, it works in the browser branch. Thanks!