Example #1
0
File: main.cpp Project: qmlos/shell
int main(int argc, char *argv[])
{
    // Disable ptrace except for gdb
    disablePtrace();

    // Setup the environment
    qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("wayland"));
    qputenv("QT_WAYLAND_USE_BYPASSWINDOWMANAGERHINT", QByteArrayLiteral("1"));

    // Application
    QGuiApplication app(argc, argv);
    app.setApplicationName(QStringLiteral("Liri Shell Helper"));
    app.setApplicationVersion(QStringLiteral(LIRI_VERSION_STRING));
    app.setOrganizationName(QStringLiteral("Liri"));
    app.setOrganizationDomain(QStringLiteral("liri.io"));
    app.setFallbackSessionManagementEnabled(false);
    app.setQuitOnLastWindowClosed(false);

    // Print version information
    qDebug("== Liri Shell Helper v%s (Green Island v%s) ==\n"
           "** http://liri.io\n"
           "** Bug reports to: https://github.com/lirios/shell/issues\n"
           "** Build: %s-%s",
           LIRI_VERSION_STRING, GREENISLAND_VERSION_STRING,
           LIRI_VERSION_STRING, GIT_REV);

    // Create shell helper
    new ShellHelperApplication();

    return app.exec();
}
Example #2
0
int main(int argc, char *argv[])
{
    // Disable ptrace except for gdb
    disablePtrace();

    // Setup the environment
    setupEnvironment();

    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

    // Application
    QApplication app(argc, argv);
    app.setApplicationName(QLatin1String("Papyros Shell"));
    app.setApplicationVersion(QLatin1String(PAPYROS_SHELL_VERSION_STRING));
    app.setOrganizationName(QLatin1String("Ppayros"));
    app.setOrganizationDomain(QLatin1String("papyros.io"));
    app.setFallbackSessionManagementEnabled(false);
    app.setQuitOnLastWindowClosed(false);

    // Command line parser
    QCommandLineParser parser;
    parser.setApplicationDescription(TR("Wayland compositor for the Papyros desktop environment"));
    parser.addHelpOption();
    parser.addVersionOption();

    // Wayland socket
    QCommandLineOption socketOption(QStringLiteral("wayland-socket-name"), TR("Wayland socket"),
                                    TR("name"));
    parser.addOption(socketOption);

    // Nested mode
    QCommandLineOption nestedOption(
            QStringList() << QStringLiteral("n") << QStringLiteral("nested"),
            TR("Nest into a compositor that supports _wl_fullscreen_shell"));
    parser.addOption(nestedOption);

    // Fake screen configuration
    QCommandLineOption fakeScreenOption(QStringLiteral("fake-screen"),
                                        TR("Use fake screen configuration"), TR("filename"));
    parser.addOption(fakeScreenOption);

#if DEVELOPMENT_BUILD
    // Load shell from an arbitrary path
    QCommandLineOption qmlOption(QStringLiteral("qml"),
                                 QStringLiteral("Load a shell main QML file"),
                                 QStringLiteral("filename"));
    parser.addOption(qmlOption);
#endif

    // Parse command line
    parser.process(app);

    // Restart with D-Bus session if necessary
    if (qEnvironmentVariableIsEmpty("DBUS_SESSION_BUS_ADDRESS")) {
        qCritical("No D-Bus session bus available, please run Hawaii with dbus-launch.");
        return 1;
    }

    // Arguments
    bool nested = parser.isSet(nestedOption);
    QString socket = parser.value(socketOption);
    QString fakeScreenData = parser.value(fakeScreenOption);

    // Nested mode requires running from Wayland and a socket name
    // and fake screen data cannot be used
    if (nested) {
        if (!QGuiApplication::platformName().startsWith(QStringLiteral("greenisland"))) {
            qCritical("Nested mode only make sense when running on Wayland.\n"
                      "Please pass the \"-platform greenisland\" argument.");
            return 1;
        }

        if (socket.isEmpty()) {
            qCritical("Nested mode requires you to specify a socket name.\n"
                      "Please specify it with the \"--wayland-socket-name\" argument.");
            return 1;
        }

        if (!fakeScreenData.isEmpty()) {
            qCritical("Fake screen configuration cannot be used when nested");
            return 1;
        }
    }

    // Print version information
    qDebug("== Papyros Shell v%s (Green Island v%s) ==\n"
           "** http://papyros.io\n"
           "** Bug reports to: https://github.com/papyros/papyros-shell/issues\n"
           "** Build: %s-%s",
           PAPYROS_SHELL_VERSION_STRING, GREENISLAND_VERSION_STRING, PAPYROS_SHELL_VERSION_STRING,
           GIT_REV);

    // Application
    Application *papyros = new Application();
    papyros->setScreenConfiguration(fakeScreenData);

    // Create the compositor and run
    bool urlAlreadySet = false;
#if DEVELOPMENT_BUILD
    if (parser.isSet(qmlOption)) {
        urlAlreadySet = true;
        papyros->setUrl(QUrl::fromLocalFile(parser.value(qmlOption)));
    }
#endif
    if (!urlAlreadySet)
        papyros->setUrl(QUrl(QStringLiteral("qrc:/Compositor.qml")));
    QCoreApplication::postEvent(papyros, new StartupEvent());

    return app.exec();
}