[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():
|
def _get_layouts():
|
||||||
"""Loads and parses the arandr screen layout scripts."""
|
"""Loads and parses the arandr screen layout scripts."""
|
||||||
layouts = {}
|
layouts = {}
|
||||||
for filename in os.listdir(__screenlayout_dir__):
|
try:
|
||||||
if fnmatch.fnmatch(filename, '*.sh'):
|
for filename in os.listdir(__screenlayout_dir__):
|
||||||
fullpath = os.path.join(__screenlayout_dir__, filename)
|
if fnmatch.fnmatch(filename, '*.sh'):
|
||||||
with open(fullpath, "r") as file:
|
fullpath = os.path.join(__screenlayout_dir__, filename)
|
||||||
for line in file:
|
with open(fullpath, "r") as file:
|
||||||
s_line = line.strip()
|
for line in file:
|
||||||
if "xrandr" not in s_line:
|
s_line = line.strip()
|
||||||
continue
|
if "xrandr" not in s_line:
|
||||||
displays_in_file = Module._parse_layout(line)
|
continue
|
||||||
layouts[filename] = displays_in_file
|
displays_in_file = Module._parse_layout(line)
|
||||||
|
layouts[filename] = displays_in_file
|
||||||
|
except Exception as e:
|
||||||
|
log.error(str(e))
|
||||||
return layouts
|
return layouts
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Reference in a new issue