[modules/arandr] handle case of "no layouts exist
To ensure that arandr works also if no layouts are available, add some (very simplistic) exception handling. see #844
This commit is contained in:
parent
1089792bc6
commit
8bde6378d4
1 changed files with 13 additions and 10 deletions
|
@ -136,16 +136,19 @@ class Module(core.module.Module):
|
|||
def _get_layouts():
|
||||
"""Loads and parses the arandr screen layout scripts."""
|
||||
layouts = {}
|
||||
for filename in os.listdir(__screenlayout_dir__):
|
||||
if fnmatch.fnmatch(filename, '*.sh'):
|
||||
fullpath = os.path.join(__screenlayout_dir__, filename)
|
||||
with open(fullpath, "r") as file:
|
||||
for line in file:
|
||||
s_line = line.strip()
|
||||
if "xrandr" not in s_line:
|
||||
continue
|
||||
displays_in_file = Module._parse_layout(line)
|
||||
layouts[filename] = displays_in_file
|
||||
try:
|
||||
for filename in os.listdir(__screenlayout_dir__):
|
||||
if fnmatch.fnmatch(filename, '*.sh'):
|
||||
fullpath = os.path.join(__screenlayout_dir__, filename)
|
||||
with open(fullpath, "r") as file:
|
||||
for line in file:
|
||||
s_line = line.strip()
|
||||
if "xrandr" not in s_line:
|
||||
continue
|
||||
displays_in_file = Module._parse_layout(line)
|
||||
layouts[filename] = displays_in_file
|
||||
except Exception as e:
|
||||
log.error(str(e))
|
||||
return layouts
|
||||
|
||||
@staticmethod
|
||||
|
|
Loading…
Reference in a new issue