cleaner way to activate a layout

This commit is contained in:
Zero Rust 2020-05-23 07:28:00 -04:00
parent ffd04e9710
commit 90fbc249af

View file

@ -40,6 +40,11 @@ class Module(core.module.Module):
core.input.register(self, button=core.input.RIGHT_MOUSE, core.input.register(self, button=core.input.RIGHT_MOUSE,
cmd=self.popup) cmd=self.popup)
def activate_layout(self, layout_path):
log.debug("activating layout")
log.debug(layout_path)
execute(layout_path)
def popup(self, widget): def popup(self, widget):
"""Create Popup that allows the user to control their displays in one """Create Popup that allows the user to control their displays in one
of three ways: launch arandr, select a pre-set screenlayout, toggle a of three ways: launch arandr, select a pre-set screenlayout, toggle a
@ -61,10 +66,8 @@ class Module(core.module.Module):
for layout in available_layouts: for layout in available_layouts:
sh = os.path.join(__screenlayout_dir__, layout) sh = os.path.join(__screenlayout_dir__, layout)
sh_name = os.path.splitext(layout)[0] sh_name = os.path.splitext(layout)[0]
cmd = self.parameter(sh_name, sh)
menu.add_menuitem(sh_name, menu.add_menuitem(sh_name,
callback=partial(util.cli.execute, sh) callback=partial(self.activate_layout, sh))
)
menu.show(widget, 0, 0) menu.show(widget, 0, 0)