feat: add methods to check if running from a sandbox, flatpak and or snap
This commit is contained in:
parent
087afd22b2
commit
9fe445ebd0
1 changed files with 29 additions and 0 deletions
|
|
@ -1,11 +1,13 @@
|
||||||
/*
|
/*
|
||||||
* Deskflow -- mouse and keyboard sharing utility
|
* Deskflow -- mouse and keyboard sharing utility
|
||||||
|
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||||
* SPDX-FileCopyrightText: (C) 2024 Symless Ltd.
|
* SPDX-FileCopyrightText: (C) 2024 Symless Ltd.
|
||||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QFileInfo>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace deskflow::platform {
|
namespace deskflow::platform {
|
||||||
|
|
@ -34,4 +36,31 @@ inline bool isWayland()
|
||||||
return session != nullptr && std::string(session) == "wayland";
|
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
|
} // namespace deskflow::platform
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue