From 9fe445ebd009812e631007777514a93f81248f80 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Sat, 9 Aug 2025 08:58:46 -0400 Subject: [PATCH] feat: add methods to check if running from a sandbox, flatpak and or snap --- src/lib/platform/Wayland.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/lib/platform/Wayland.h b/src/lib/platform/Wayland.h index bf4056bd8..d4950ea30 100644 --- a/src/lib/platform/Wayland.h +++ b/src/lib/platform/Wayland.h @@ -1,11 +1,13 @@ /* * Deskflow -- mouse and keyboard sharing utility + * SPDX-FileCopyrightText: (C) 2025 Deskflow Developers * SPDX-FileCopyrightText: (C) 2024 Symless Ltd. * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception */ #pragma once +#include #include namespace deskflow::platform { @@ -34,4 +36,31 @@ inline bool isWayland() return session != nullptr && std::string(session) == "wayland"; } +/** + * @brief isFlatpak + * @return Returns true if we are running as flatpak + */ +inline bool isFlatpak() +{ + return QFileInfo::exists(QStringLiteral("/.flatpak-info")); +} + +/** + * @brief isSnap + * @return Returns true if we are running as a snap + */ +inline bool isSnap() +{ + return qEnvironmentVariableIsSet("SNAP"); +} + +/** + * @brief isSandboxed + * @return Returns true if we are running from in a known sandbox. + */ +inline bool isSandboxed() +{ + return isFlatpak() || isSnap(); +} + } // namespace deskflow::platform