def run(self): """Record opacity changes until stop signal received.""" while self.keep_going: opacity = xutil.request_opacity(self.window).unpack() if opacity != self.opacity_events[-1]: self.opacity_events.append(opacity) self.done = True
def flash_window(self, window): """Briefly change the opacity of a Xorg window.""" log('Flashing window %s', str(window)) try: pre_flash_opacity = xutil.request_opacity(window).unpack() log('Current opacity = %s', str(pre_flash_opacity)) log('Beginning flash animation...') flash_series = self.compute_flash_series(pre_flash_opacity) for opacity in flash_series: xutil.set_opacity(window, opacity) sleep(self.timechunk) log('Resetting opacity to default') if pre_flash_opacity: xutil.set_opacity(window, pre_flash_opacity) else: xutil.delete_opacity(window) except WindowError: log('Attempted to flash a nonexistant window %s, ignoring...', str(window)) log('Unlocking window %s', window) self.locked_windows.discard(window)
def test_get_set_opacity(window): assert not xutil.request_opacity(window).unpack() xutil.set_opacity(window, 0.5) assert xutil.request_opacity(window).unpack() == approx(0.5, 0.00001)
def test_delete_opacity(window): xutil.set_opacity(window, 0.5) assert xutil.request_opacity(window).unpack() xutil.delete_opacity(window) assert not xutil.request_opacity(window).unpack()
def __init__(self, window): super(WindowWatcher, self).__init__() self.window = window self.opacity_events = [xutil.request_opacity(self.window).unpack()] self.keep_going = True self.done = False