From 1f728c137d3c25ded9a7c46a0400ebb0556035fd Mon Sep 17 00:00:00 2001 From: Adam Gausmann Date: Fri, 12 May 2023 02:41:33 -0500 Subject: [PATCH] Catch error when sway cannot be reached --- install.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/install.py b/install.py index 2a47d82..8f9f431 100755 --- a/install.py +++ b/install.py @@ -113,14 +113,18 @@ def main(): # This will only work if this is run on the target host # and if sway is running, but that is usually the case... if output['match'] != '*': - get_outputs = subprocess.check_output( - ['swaymsg', '-t', 'get_outputs', '-p'], - ).decode('utf-8') - for line in get_outputs.splitlines(): - # Line format: Output '' - if line.startswith('Output') and output['match'] in line: - output['device'] = line.split()[1] - break + try: + get_outputs = subprocess.check_output( + ['swaymsg', '-t', 'get_outputs', '-p'], + ).decode('utf-8') + for line in get_outputs.splitlines(): + # Line format: Output '' + if line.startswith('Output') and output['match'] in line: + output['device'] = line.split()[1] + break + except subprocess.CalledProcessError: + print('Could not contact sway to retrieve output names.') + print('Please re-run in sway to finish configuring swaylock.') lookup = mako.lookup.TemplateLookup( directories=[