add flatpak support with docker and terminal

This commit is contained in:
Salem Yaslem 2024-09-28 19:01:32 +03:00
parent 13d16fac31
commit cad5588b72
2 changed files with 31 additions and 6 deletions

View File

@ -7,6 +7,21 @@
"base-version": "5.15-23.08",
"command": "qocker",
"modules": [
{
"name": "docker-cli",
"buildsystem": "simple",
"build-commands": [
"tar xzvf docker-20.10.9.tgz",
"install -D docker/docker /app/bin/docker"
],
"sources": [
{
"type": "file",
"url": "https://download.docker.com/linux/static/stable/x86_64/docker-20.10.9.tgz",
"sha256": "caf74e54b58c0b38bb4d96c8f87665f29b684371c9a325562a3904b8c389995e"
}
]
},
{
"name": "qocker",
"buildsystem": "simple",
@ -15,9 +30,8 @@
],
"sources": [
{
"type": "git",
"url": "https://github.com/xlmnxp/qocker.git",
"tag": "v0.2"
"type": "dir",
"path": ".."
}
]
}
@ -26,6 +40,9 @@
"--share=network",
"--socket=fallback-x11",
"--socket=wayland",
"--filesystem=/run/docker.sock"
"--env=DOCKER_HOST=unix:///run/docker.sock",
"--filesystem=/run/docker.sock",
"--system-talk-name=org.freedesktop.DBus",
"--socket=session-bus"
]
}

12
main.py
View File

@ -1,5 +1,6 @@
#!/usr/bin/env python3
import sys
import os
from PyQt5.QtWidgets import (QApplication, QMainWindow, QTabWidget, QTreeWidget, QTreeWidgetItem,
QVBoxLayout, QHBoxLayout, QWidget, QToolBar, QAction, QMenu,
QHeaderView, QLabel, QLineEdit, QCheckBox, QMessageBox, QInputDialog)
@ -41,7 +42,11 @@ class TerminalOpener(QThread):
if system == "Darwin": # macOS
subprocess.Popen(['open', '-a', 'Terminal', '--', 'sh', '-c', f"{docker_command}"])
elif system == "Linux":
subprocess.Popen(['x-terminal-emulator', '-e', f'sh -c "{docker_command}"'])
# check if inside flatpak
if 'container' in os.environ:
subprocess.Popen(['flatpak-spawn', '--host', 'x-terminal-emulator', '-e', f'sh -c "{docker_command}"'])
else:
subprocess.Popen(['x-terminal-emulator', '-e', f'sh -c "{docker_command}"'])
elif system == "Windows":
subprocess.Popen(['start', 'cmd', '/k', docker_command], shell=True)
else:
@ -64,7 +69,10 @@ class LogsOpener(QThread):
if system == "Darwin": # macOS
subprocess.Popen(['open', '-a', 'Terminal', '--', 'sh', '-c', f"{docker_command}"])
elif system == "Linux":
subprocess.Popen(['x-terminal-emulator', '-e', f'sh -c "{docker_command}"'])
if 'container' in os.environ:
subprocess.Popen(['flatpak-spawn', '--host', 'x-terminal-emulator', '-e', f'sh -c "{docker_command}"'])
else:
subprocess.Popen(['x-terminal-emulator', '-e', f'sh -c "{docker_command}"'])
elif system == "Windows":
subprocess.Popen(['start', 'cmd', '/k', docker_command], shell=True)
else: