diff --git a/multibrowse.py b/multibrowse.py index a6a6e03..52cc499 100755 --- a/multibrowse.py +++ b/multibrowse.py @@ -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)) diff --git a/systems/linux.py b/systems/linux.py index 560e375..57a8000 100644 --- a/systems/linux.py +++ b/systems/linux.py @@ -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)