Skip to content

Commit

Permalink
Linux: Add build option to disable autostart
Browse files Browse the repository at this point in the history
Autostart option should not be available for example for flatpack apps
since it is handled by a background portal.

Fixes #2517
  • Loading branch information
hluk committed Oct 25, 2023
1 parent 19e9dd1 commit 6a0ede8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ if (UNIX AND NOT APPLE)
set(BASH_COMPLETION_INSTALL_PREFIX "${DATA_INSTALL_PREFIX}/bash-completion/completions/" CACHE PATH "Install path for bash completions")
set(ICON_NAME "copyq" CACHE STRING "Name for icon files")
set(COPYQ_AUTOSTART_COMMAND "" CACHE STRING "Autostart command")
OPTION(COPYQ_AUTOSTART "Enable autostart option" ON)
endif()

set(CMAKE_AUTOMOC ON)
Expand Down Expand Up @@ -193,6 +194,10 @@ if (UNIX AND NOT APPLE)
add_definitions( -DCOPYQ_BASH_COMPLETION_PREFIX="${BASH_COMPLETION_INSTALL_PREFIX}" )
add_definitions( -DCOPYQ_ICON_NAME="${ICON_NAME}" )

if (COPYQ_AUTOSTART)
add_definitions( -DCOPYQ_AUTOSTART )
endif()

if (COPYQ_AUTOSTART_COMMAND)
add_definitions( -DCOPYQ_AUTOSTART_COMMAND="${COPYQ_AUTOSTART_COMMAND}" )
endif()
Expand Down
6 changes: 3 additions & 3 deletions src/platform/x11/x11platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ PlatformWindowPtr X11Platform::getCurrentWindow()

bool X11Platform::canAutostart()
{
#ifdef COPYQ_DESKTOP_FILE
#if defined(COPYQ_AUTOSTART) && defined(COPYQ_DESKTOP_FILE)
return true;
#else
return false;
Expand All @@ -123,7 +123,7 @@ bool X11Platform::canAutostart()

bool X11Platform::isAutostartEnabled()
{
#ifdef COPYQ_DESKTOP_FILE
#if defined(COPYQ_AUTOSTART) && defined(COPYQ_DESKTOP_FILE)
const QString filename = getDesktopFilename();

QFile desktopFile(filename);
Expand Down Expand Up @@ -153,7 +153,7 @@ bool X11Platform::isAutostartEnabled()

void X11Platform::setAutostartEnabled(bool enable)
{
#ifdef COPYQ_DESKTOP_FILE
#if defined(COPYQ_AUTOSTART) && defined(COPYQ_DESKTOP_FILE)
if ( isAutostartEnabled() == enable )
return;

Expand Down

0 comments on commit 6a0ede8

Please sign in to comment.