Add cutefish booster

pull/1/head
reionwong 4 years ago
parent bb3384e7fb
commit 010c97ffcb

@ -4,9 +4,8 @@ add_subdirectory(invoker)
# Sub build: launcher library
add_subdirectory(launcherlib)
# Sub build: generic booster plugin
add_subdirectory(booster-generic)
# Sub build: single-instance binary / library
add_subdirectory(single-instance)
# Sub build: cutefish app booster plugin
add_subdirectory(cutefish-appmotor)

@ -1,25 +0,0 @@
set(LAUNCHER "${CMAKE_HOME_DIRECTORY}/src/launcherlib")
set(COMMON "${CMAKE_HOME_DIRECTORY}/src/common")
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${COMMON} ${LAUNCHER})
# Hide all symbols except the ones explicitly exported in the code (like main())
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
# Set sources
set(SRC booster-generic.cpp)
# Set libraries to be linked.
link_libraries("-L../launcherlib -lapplauncherd" ${LIBDL})
# Set executable
add_executable(booster-generic ${SRC} ${MOC_SRC})
add_dependencies(booster-generic applauncherd)
# Add install rule
install(TARGETS booster-generic DESTINATION ${CMAKE_INSTALL_FULL_LIBEXECDIR}/mapplauncherd/)
if(INSTALL_SYSTEMD_UNITS)
install(FILES booster-generic.service DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/systemd/user/)
install(FILES booster-generic@.service DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/systemd/user/)
endif()

@ -1,14 +0,0 @@
[Unit]
Description=Generic application launch booster
After=dbus.socket
Requires=dbus.socket
[Service]
Type=notify
ExecStart=/usr/libexec/mapplauncherd/booster-generic --systemd
Restart=always
RestartSec=1
OOMScoreAdjust=-250
[Install]
WantedBy=user-session.target

@ -1,11 +0,0 @@
[Unit]
Description=Generic application launch booster (sandboxed)
Requires=dbus.socket booster-silica-session.path lipstick.service
After=dbus.service booster-silica-session.path lipstick.service
[Service]
Type=simple
ExecStart=/usr/bin/invoker --type=silica-session -- /usr/bin/sailjail --profile=%i -- /usr/libexec/mapplauncherd/booster-generic --application=%i
Restart=always
RestartSec=1
OOMScoreAdjust=-250

@ -0,0 +1,40 @@
set(LAUNCHER "${CMAKE_HOME_DIRECTORY}/src/launcherlib")
set(COMMON "${CMAKE_HOME_DIRECTORY}/src/common")
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${COMMON} ${LAUNCHER})
set(QT Widgets Quick QuickControls2)
find_package(Qt5 REQUIRED ${QT})
# Hide all symbols except the ones explicitly exported in the code (like main())
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed
set(CMAKE_AUTOMOC ON)
# Create code from a list of Qt designer ui files
set(CMAKE_AUTOUIC ON)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_VERBOSE_MAKEFILE ON)
# Set sources
set(SRC cutefish-appmotor.cpp)
# Set libraries to be linked.
link_libraries("-L../launcherlib -lapplauncherd" ${LIBDL})
# Set executable
add_executable(cutefish-appmotor ${SRC} ${MOC_SRC})
target_link_libraries(cutefish-appmotor
Qt5::Widgets
Qt5::Quick
)
# Add install rule
install(TARGETS cutefish-appmotor DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
if(INSTALL_SYSTEMD_UNITS)
install(FILES cutefish-appmotor.service DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/systemd/user/)
endif()

@ -17,27 +17,24 @@
**
****************************************************************************/
#include "booster-generic.h"
#include "launcherlib.h"
#include "cutefish-appmotor.h"
#include "daemon.h"
#include "logger.h"
#include <errno.h>
#include <string.h>
#include <unistd.h>
const string EBooster::m_boosterType = "generic";
#include <QQuickView>
#include <QtGlobal>
#include <QApplication>
#include <QDebug>
const string & EBooster::boosterType() const
{
return m_boosterType;
}
const string CutefishBooster::m_boosterType = "cutefish";
bool EBooster::preload()
const string & CutefishBooster::boosterType() const
{
return true;
return m_boosterType;
}
int EBooster::launchProcess()
int CutefishBooster::launchProcess()
{
Booster::setEnvironmentBeforeLaunch();
@ -61,9 +58,24 @@ int EBooster::launchProcess()
return EXIT_FAILURE;
}
void CutefishBooster::initialize(int initialArgc, char **initialArgv, int boosterLauncherSocket,
int socketFd, SingleInstance *singleInstance, bool bootMode)
{
new QApplication(initialArgc, initialArgv);
Booster::initialize(initialArgc, initialArgv, boosterLauncherSocket, socketFd, singleInstance, bootMode);
}
bool CutefishBooster::preload()
{
QQuickView window;
window.create();
return true;
}
int main(int argc, char **argv)
{
EBooster *booster = new EBooster;
CutefishBooster *booster = new CutefishBooster;
Daemon d(argc, argv);
d.run(booster);

@ -17,51 +17,48 @@
**
****************************************************************************/
#ifndef BOOSTER_GENERIC_H
#define BOOSTER_GENERIC_H
#ifndef CUTEFISH_APPMOTOR_H
#define CUTEFISH_APPMOTOR_H
#include "booster.h"
/*!
\class EBooster
\brief EBooster is a "booster" that only exec()'s the given binary.
This can be used to launch any application.
* \class CutefishBooster.
* \brief Qt-specific version of the Booster.
*/
class EBooster : public Booster
class CutefishBooster : public Booster
{
public:
EBooster() {}
virtual ~EBooster() {}
//! Constructor.
CutefishBooster() {};
//! Destructor.
virtual ~CutefishBooster() {};
//! \reimp
virtual const string & boosterType() const;
protected:
virtual void initialize(int initialArgc, char ** initialArgv, int boosterLauncherSocket,
int socketFd, SingleInstance * singleInstance,
bool bootMode) override;
//! \reimp
virtual int launchProcess();
protected:
//! \reimp
virtual bool preload();
virtual int launchProcess();
private:
//! Disable copy-constructor
EBooster(const EBooster & r);
CutefishBooster(const CutefishBooster & r);
//! Disable assignment operator
EBooster & operator= (const EBooster & r);
CutefishBooster & operator= (const CutefishBooster & r);
static const string m_boosterType;
//! wait for socket connection
void accept();
#ifdef UNIT_TEST
friend class Ut_EBooster;
#endif
};
#endif // EBooster_H
#endif //QTBOOSTER_H

@ -0,0 +1,13 @@
[Unit]
Description=Cutefish Application Launch Booster
After=display-manager.service
[Service]
Type=notify
ExecStart=/usr/bin/cutefish-appmotor --systemd
Restart=always
RestartSec=1
OOMScoreAdjust=-250
[Install]
WantedBy=default.target

@ -583,7 +583,7 @@ static void usage(int status)
"launch anything. Possible values for TYPE:\n"
" qt5 Launch a Qt 5 application.\n"
" qtquick2 Launch a Qt Quick 2 (QML) application.\n"
" silica-qt5 Launch a Sailfish Silica application.\n"
" cutefish Launch a Cutefish application.\n"
" generic Launch any application, even if it's not a library.\n"
"\n"
"The TYPE may also be a comma delimited list of boosters to try. The first available\n"
@ -615,7 +615,7 @@ static void usage(int status)
" -h, --help Print this help.\n"
" -v, --verbose Make invoker more verbose. Can be given several times.\n"
"\n"
"Example: %s --type=qt5 /usr/bin/helloworld\n"
"Example: %s --type=cutefish /usr/bin/helloworld\n"
"\n",
PROG_NAME_INVOKER, EXIT_DELAY, RESPAWN_DELAY, MAX_RESPAWN_DELAY, PROG_NAME_INVOKER);

Loading…
Cancel
Save