def error(msg, exit=0): print '[Snap] <<ERROR>>', msg if exit: sys.exit(exit) if __name__ == '__main__': # create the module to interface with Fvwm m = FvwmModule(sys.argv) # read configuration lines. We're only looking for those that # start with `*Snap' snappers = {} for config in m.get_configinfo().get_infolines('Snap'): try: [ignore, snapper, x, y, w, h] = config.split() snappers[snapper] = [x, y, w, h] except ValueError: error('Ignoring badly formed line: %s' % config) # now figure out where you want to snap to snapto = m.args[0] try: [x, y, w, h] = snappers[snapto] window = int(m.appcontext, 16) except KeyError: error("Don't know how to snap to: %s" % snapto, -1) except ValueError: error("Whoa Nelly! Can't get a window number: %s" % m.appcontext, -2) # do the snapping m.send('Move %s %s' % (x, y), window, cont=1) m.send('Resize %s %s' % (w, h), window, cont=1) m.send('Focus', window, cont=0)
def error(msg, exit=0): print '[Snap] <<ERROR>>', msg if exit: sys.exit(exit) if __name__ == '__main__': # create the module to interface with Fvwm m = FvwmModule(sys.argv) # read configuration lines. We're only looking for those that # start with `*Snap' snappers = {} for config in m.get_configinfo().get_infolines('Snap'): try: [ignore, snapper, x, y, w, h] = string.split(config) snappers[snapper] = [x, y, w, h] except ValueError: error('Ignoring badly formed line: %s' % config) # now figure out where you want to snap to snapto = m.args[0] try: [x, y, w, h] = snappers[snapto] window = string.atoi(m.appcontext, 16) except KeyError: error("Don't know how to snap to: %s" % snapto, -1) except ValueError: error("Whoa Nelly! Can't get a window number: %s" % m.appcontext, -2) # do the snapping m.send('Move %s %s' % (x, y), window, cont=1) m.send('Resize %s %s' % (w, h), window, cont=1) m.send('Focus', window, cont=0)
def send(self, command, window=WINDOW_NONE, cont=1): log("send: %s" % command) return FvwmModule.send(self, command, window, cont)
def send(self, command, window=WINDOW_NONE, cont=1): log("send: %s" % command) return FvwmModule.send(self, command, window, cont)