Skip to content

Commit 6b0fc75

Browse files
authored
Merge pull request #1541 from larchunix/flatpak_stats
stats: detect flatpak sandbox at runtime
2 parents aa4af48 + 0e56127 commit 6b0fc75

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,6 @@ if(SNAP_BUILD)
183183
add_definitions(-DSNAP_BUILD)
184184
endif()
185185

186-
if(FLATPAK_BUILD)
187-
add_definitions(-DFLATPAK_BUILD)
188-
endif()
189-
190186
# Uninstall support
191187
configure_file(
192188
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"

flatpak/org.remmina.Remmina.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,7 @@
472472
"config-opts": [
473473
"-DCMAKE_BUILD_TYPE:STRING=Release",
474474
"-DWITH_MANPAGES:BOOL=OFF",
475-
"-DWITH_TELEPATHY:BOOL=OFF",
476-
"-DFLATPAK_BUILD:BOOL=ON"
475+
"-DWITH_TELEPATHY:BOOL=OFF"
477476
],
478477
"sources": [
479478
{

remmina/src/remmina_stats.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ JsonNode *remmina_stats_get_version()
344344
TRACE_CALL(__func__);
345345
JsonBuilder *b;
346346
JsonNode *r;
347+
gchar *flatpak_info;
347348

348349
/** @warning this function is usually executed on a dedicated thread,
349350
* not on the main thread */
@@ -361,12 +362,18 @@ JsonNode *remmina_stats_get_version()
361362
json_builder_add_int_value(b, 0);
362363
#endif
363364

365+
/**
366+
* Detect if we are running under Flatpak
367+
*/
364368
json_builder_set_member_name(b, "flatpak_build");
365-
#ifdef FLATPAK_BUILD
366-
json_builder_add_int_value(b, 1);
367-
#else
368-
json_builder_add_int_value(b, 0);
369-
#endif
369+
/* Flatpak sandbox should contain the file ${XDG_RUNTIME_DIR}/flatpak-info */
370+
flatpak_info = g_build_filename(g_get_user_runtime_dir(), "flatpak-info", NULL);
371+
if (g_file_test(flatpak_info, G_FILE_TEST_EXISTS)) {
372+
json_builder_add_int_value(b, 1);
373+
} else {
374+
json_builder_add_int_value(b, 0);
375+
}
376+
g_free(flatpak_info);
370377

371378
json_builder_end_object(b);
372379
r = json_builder_get_root(b);

0 commit comments

Comments
 (0)