def expression(ctx, value): with InfiniteGlass.Display() as display: try: value = json.loads(value, object_hook=InfiniteGlass.fromjson(display)) except: pass itemtype, items, fmt = InfiniteGlass.parse_value(display, value) print("%s(%s): %s" % (itemtype, fmt, items)) sys.exit(0)
def apply(self, window, action_type="set"): InfiniteGlass.DEBUG( "ghost.apply", "SHADOW APPLY %s window_id=%s %s\n" % (action_type, window, self)) sys.stderr.flush() if self.properties.get("IG_GHOSTS_DISABLED", 0): window["IG_GHOSTS_DISABLED"] = 1 else: for key in self.manager.config[action_type]: if key in self.properties: if InfiniteGlass.DEBUG_ENABLED("ghost.apply.properties"): itemtype, items, fmt = InfiniteGlass.parse_value( self.manager.display, self.properties[key]) itemtype = self.manager.display.get_atom_name(itemtype) InfiniteGlass.DEBUG( "ghost.properties", "%s=<%s/%s>%s\n" % (key, itemtype, fmt, str(items)[:100])) sys.stderr.flush() #if key == "__attributes__": # window.change_attributes(**self.properties[key]) if key == "__config__": try: window.configure(**self.properties[key]) except Exception as e: InfiniteGlass.ERROR( "ghost.properties", "Unable to configure %s[%s]\n" % (window, self.properties[key])) else: InfiniteGlass.DEBUG( "ghost.properties", " => %s[%s]\n" % (window.id, self.properties[key])) else: try: window[key] = self.properties[key] except Exception as e: InfiniteGlass.ERROR( "ghost.properties", "Unable to set property %s.%s=%s\n" % (window, key, self.properties[key])) else: InfiniteGlass.DEBUG( "ghost.properties", " => %s=%s\n" % (key, window[key])) self.manager.display.flush()