#!/usr/bin/env python """Entry point for AUIMD. If this module is run as the main module, it will : - chdir to this module path - analyse command line arguments - create a Desktop object - start a QApplication with the desktop widget as main window """ import os import sys import socket import getopt from PyQt4 import QtCore, QtGui # make sure we interpret paths relative to the location of the auimd.py entry point os.chdir(os.path.dirname(os.path.realpath(sys.argv[0]))) import dbus import dbus.mainloop.qt from core.desktop import createDesktop def usage(): print "AUIMD - Aggregated User Interface for Mobile Devices. Usage:" print print " "+sys.argv[0]+" [options]" print print "Options:" print print " -d, --device Set the hardware type (default='dummy'," print " show available='list')." print " -f, --fullscreen Use the whole screen (default=no)." print " -n, --no-cursor Hide the cursor (default=no)." print " -e, --embed Embed into an existing window." print " -h, --help Print this message." print " -D, --display X11 display to use, default : $DISPLAY" print " -g, --geometry Window geometry, overriden by --fullscreen" print def main(): try: opts, args = getopt.getopt(sys.argv[1:],"d:fne:hD:g:", \ ["device=", "fullscreen", "no-cursor", "embed=", \ "help", "display=", "geometry=" ]) except getopt.GetoptError, err: print str(err) usage() sys.exit(2) qt_argv=[sys.argv[0]] fullscreen=0 no_cursor=0 device="dummy" embed=None for o, a in opts: if o in ("-h", "--help"): usage() sys.exit() elif o in ("-f", "--fullscreen"): fullscreen = 1 elif o in ("-n", "--no-cursor"): no_cursor = 1 elif o in ("-e", "--embed"): embed = a elif o in ("-d", "--device"): if a == "list": print "Available devices : " for i in os.listdir("devices"): if os.path.exists("devices/"+i+"/device.py"): print i sys.exit(0) else: device = a elif o in ("-D", "--display"): os.environ["DISPLAY"] = a elif o in ("-g", "--geometry"): qt_argv.extend(("-geometry", a)) app=QtGui.QApplication(qt_argv) dbus.mainloop.qt.DBusQtMainLoop(set_as_default=True) dbus.SessionBus().request_name("net.pierrox.auimd") d=createDesktop(device, fullscreen, no_cursor, embed) d.show() app.exec_() if __name__=="__main__": main()