Skip to content

Commit

Permalink
feat(linux): support additional browser binaries (Chromium) instead o…
Browse files Browse the repository at this point in the history
…f only `google-chrome-stable`, close #7; add nicer error message if no browser binaries found
  • Loading branch information
foxxyz committed Jan 19, 2020
1 parent 74f8b2d commit bf741de
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion multibrowse.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,7 @@
print('Error: No display number {}'.format(index + 1), file=sys.stderr)
continue
print('Opening {} on monitor {}'.format(url, index + 1))
platform.open_browser(url, display, flags)
try:
platform.open_browser(url, display, flags)
except FileNotFoundError as e:
print("Error: {}".format(e))
14 changes: 12 additions & 2 deletions systems/linux.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
from functools import lru_cache
import re
from subprocess import call, check_output, DEVNULL
from subprocess import call, check_output, DEVNULL, CalledProcessError

from . import BaseSystem

BINARIES = [
'chromium-browser', # ubuntu/debian
'chromium', # arch
'google-chrome-stable', # arch
]

class System(BaseSystem):

@property
@lru_cache()
def browser_path(self):
return check_output(['which', 'google-chrome-stable'])[:-1].decode('utf8')
for binary in BINARIES:
try:
return check_output(['which', binary], stderr=DEVNULL)[:-1].decode('utf8')
except CalledProcessError:
pass
raise FileNotFoundError("No supported browsers found!")

def close_existing_browsers(self):
return call(['killall', '-9', 'chrome'], stdout=DEVNULL, stderr=DEVNULL)
Expand Down

0 comments on commit bf741de

Please sign in to comment.