Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ For Ubuntu/Debian systems, this might look like:
sudo apt install make cmake libglib2.0-dev libcairo2-dev librsvg2-dev libfuse-dev libarchive-dev libxpm-dev libcurl4-openssl-dev libboost-all-dev qtbase5-dev qtdeclarative5-dev qttools5-dev-tools patchelf libc6-dev libc6-dev gcc-multilib g++-multilib
```

## Options
By default, AppImageLauncher is built for System-D based systems.
OpenRC can be targeted instead by adding `-DSERVICE_TYPE="openrc"`.

## Build

Please update the `PREFIX` if you want. The prefix is the location the final application will be installed to. Usual locations may be `/usr/local` (default), `/usr`, `~/.local` or `/opt`.
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ endif()
# note: for the time being, we require AppImageUpdate to be fetched during build, even if only to make libappimage available
FetchContent_MakeAvailable(AppImageUpdate)

# choose what init service system to target (for daemon user service)
# set by adding -DSERVICE_TYPE="<type>" when calling cmake
# options: systemd, openrc
set(SERVICE_TYPE "systemd" CACHE STRING "init service provider to target")
if (SERVICE_TYPE STREQUAL "systemd")
add_definitions(-DSERVICE_TYPE_SYSTEMD)
elseif (SERVICE_TYPE STREQUAL "openrc")
add_definitions(-DSERVICE_TYPE_OPENRC)
endif()

# install resources, bundle libraries privately, etc.
# initializes important installation destination variables, therefore must be included before adding subdirectories
include(cmake/install.cmake)
Expand Down
43 changes: 32 additions & 11 deletions cmake/install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,35 @@ if(NOT BUILD_LITE)
)
endif()

# install systemd service configuration for appimagelauncherd
configure_file(
${PROJECT_SOURCE_DIR}/resources/appimagelauncherd.service.in
${PROJECT_BINARY_DIR}/resources/appimagelauncherd.service
@ONLY
)
# caution: don't use ${CMAKE_INSTALL_LIBDIR} here, it's really just lib/systemd/user
install(
FILES ${PROJECT_BINARY_DIR}/resources/appimagelauncherd.service
DESTINATION lib/systemd/user/ COMPONENT APPIMAGELAUNCHER
)
if (SERVICE_TYPE STREQUAL "systemd")
# install systemd service configuration for appimagelauncherd
configure_file(
${PROJECT_SOURCE_DIR}/resources/appimagelauncherd.service.in
${PROJECT_BINARY_DIR}/resources/appimagelauncherd.service
@ONLY
)
# caution: don't use ${CMAKE_INSTALL_LIBDIR} here, it's really just lib/systemd/user
install(
FILES ${PROJECT_BINARY_DIR}/resources/appimagelauncherd.service
DESTINATION lib/systemd/user/ COMPONENT APPIMAGELAUNCHER
)
message("Using SystemD service")
elseif (SERVICE_TYPE STREQUAL "openrc")
# install openrc service configuration for appimagelauncherd
#
# the output file name will be the name of the service
# so it must be "appimagelauncherd"
configure_file(
${PROJECT_SOURCE_DIR}/resources/appimagelauncherd_openrc.in
${PROJECT_BINARY_DIR}/resources/appimagelauncherd
@ONLY
)
install(
FILES ${PROJECT_BINARY_DIR}/resources/appimagelauncherd
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
DESTINATION etc/user/init.d COMPONENT APPIMAGELAUNCHER
)
message("Using OpenRC service")
endif()
9 changes: 9 additions & 0 deletions resources/appimagelauncherd_openrc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/sbin/openrc-run

#OpenRC user service

description="AppImageLauncher daemon"
supervisor="supervise-daemon"
respawn_delay=10
command="@CMAKE_INSTALL_PREFIX@/bin/appimagelauncherd"
output_log="${XDG_STATE_HOME}/appimagelauncherd"
12 changes: 12 additions & 0 deletions src/ui/settings_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ void SettingsDialog::saveSettings() {
void SettingsDialog::toggleDaemon() {
// assumes defaults if config doesn't exist or lacks the related key(s)
if (settingsFile) {
#ifdef SERVICE_TYPE_SYSTEMD
if (settingsFile->value("AppImageLauncher/enable_daemon", "true").toBool()) {
system("systemctl --user enable appimagelauncherd.service");
// we want to actually restart the service to apply the new configuration
Expand All @@ -165,6 +166,17 @@ void SettingsDialog::toggleDaemon() {
system("systemctl --user disable appimagelauncherd.service");
system("systemctl --user stop appimagelauncherd.service");
}
#elif SERVICE_TYPE_OPENRC
if (settingsFile->value("AppImageLauncher/enable_daemon", "true").toBool()) {
// enable service and restart
system("rc-update add --user appimagelauncherd default");
system("rc-service --user appimagelauncherd restart");
} else {
// disable service and stop it
system("rc-update del --user appimagelauncherd default");
system("rc-service --user appimagelauncherd stop");
}
#endif
}
}

Expand Down