From f5c927229161df2e52ba1ce4f879a7b5d585edb4 Mon Sep 17 00:00:00 2001 From: Zero Rust Date: Fri, 22 May 2020 22:44:38 -0400 Subject: [PATCH] first go at popup functionality for arandr --- bumblebee_status/modules/contrib/arandr.py | 29 ++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/bumblebee_status/modules/contrib/arandr.py b/bumblebee_status/modules/contrib/arandr.py index 7d7960f..7bbd84c 100644 --- a/bumblebee_status/modules/contrib/arandr.py +++ b/bumblebee_status/modules/contrib/arandr.py @@ -7,22 +7,47 @@ Requires the following executable: * xrandr """ +from functools import partial +import logging + import core.module import core.widget import core.input import core.decorators +import util.cli +from util import popup +from util.cli import execute + + +log = logging.getLogger(__name__) class Module(core.module.Module): @core.decorators.never def __init__(self, config, theme): - super().__init__(config, theme, core.widget.Widget("")) + super().__init__(config, theme, core.widget.Widget('')) + self.manager = self.parameter("manager", "arandr") core.input.register( self, button=core.input.LEFT_MOUSE, - cmd="arandr", + cmd=self.popup, ) + core.input.register(self, button=core.input.RIGHT_MOUSE, + cmd=self.popup) + + def popup(self, widget): + """Create Popup that allows the user to control their displays in one + of three ways: launch arandr, select a pre-set screenlayout, toggle a + display. + """ + log.info("arandr showing popup") + menu = popup.menu() + menu.add_menuitem("arandr", + callback=partial(execute, self.manager) + ) + + menu.show(widget, 0, 0) # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4