first go at popup functionality for arandr

This commit is contained in:
Zero Rust 2020-05-22 22:44:38 -04:00
parent 2fcd277cf9
commit f5c9272291

View file

@ -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