fix: open Flatpak apps in renamed app variants (#1192)

Flatpak starts bwrap with an empty environment, so the bwrap shim lost DROIDDECK_BWRAP_SOCKET and dialled the default package's socket. The session now writes the socket name to /etc/droiddeck/bwrap-socket and the shim reads it when the variable is missing.

Fixes #1092
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-10-20 09:38:14 -04:00
1 parent 99ab6dd64e
commit 31a6c3d033
4 files changed
+61 -1

No files matched your search

@@ -7,7 +7,21 @@ import socket
import struct
import sys
SOCKET = "\0" + os.environ.get("DROIDDECK_BWRAP_SOCKET", "com.droiddeck.launcher.bwrap")
SOCKET_FILE = "/etc/droiddeck/bwrap-socket"
def socket_name():
name = os.environ.get("DROIDDECK_BWRAP_SOCKET", "")
if not name:
try:
with open(SOCKET_FILE, encoding="utf-8") as f:
name = f.read().strip()
except OSError:
pass
return "\0" + (name or "com.droiddeck.launcher.bwrap")
SOCKET = socket_name()
VERSION = "bubblewrap 0.11.0 (droiddeck)"
NO_ARG = {
+36
View File
@@ -0,0 +1,36 @@
import os
import runpy
import shutil
import tempfile
import unittest
from pathlib import Path
from unittest import mock
BWRAP = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin/droiddeck-bwrap"
class BwrapSocketTest(unittest.TestCase):
def setUp(self):
self.dir = Path(tempfile.mkdtemp())
self.addCleanup(shutil.rmtree, self.dir, True)
self.shim = runpy.run_path(str(BWRAP))
self.shim["socket_name"].__globals__["SOCKET_FILE"] = str(self.dir / "bwrap-socket")
def name(self, env):
with mock.patch.dict(os.environ, env, clear=True):
return self.shim["socket_name"]()
def test_flatpak_empty_environment_reaches_a_renamed_package(self):
(self.dir / "bwrap-socket").write_text("com.antutu.benchmark.full.bwrap\n")
self.assertEqual("\0com.antutu.benchmark.full.bwrap", self.name({}))
def test_the_environment_still_wins(self):
(self.dir / "bwrap-socket").write_text("com.antutu.benchmark.full.bwrap\n")
self.assertEqual("\0com.tencent.ig.bwrap", self.name({"DROIDDECK_BWRAP_SOCKET": "com.tencent.ig.bwrap"}))
def test_without_either_the_standard_package_is_asked(self):
self.assertEqual("\0com.droiddeck.launcher.bwrap", self.name({}))
if __name__ == "__main__":
unittest.main()