feat: add methods to check if running from a sandbox, flatpak and or snap

This commit is contained in:
sithlord48
2025-08-09 08:58:46 -04:00
committed by Chris Rizzitello
parent 087afd22b2
commit 9fe445ebd0

View File

@ -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 <QFileInfo>
#include <string>
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