diff --git a/.gitignore b/.gitignore index 465d3eb..8b86ded 100644 --- a/.gitignore +++ b/.gitignore @@ -133,4 +133,5 @@ dmypy.json deb_dist .DS_Store install/windows/Dangerzone.wxs -test_docs/sample-safe.pdf \ No newline at end of file +test_docs/sample-safe.pdf +share/bin \ No newline at end of file diff --git a/BUILD.md b/BUILD.md index c68b2da..6487cc8 100644 --- a/BUILD.md +++ b/BUILD.md @@ -58,6 +58,12 @@ If you don't have it already, install poetry (`pip3 install --user poetry`). The poetry install ``` +Make sure Docker Desktop is installed (Dangerzone copies hyperkit and vpnkit binaries from it) and run this to collect the binaries: + +``` +./install/macos/collect-bins.sh +``` + Run from source tree: ``` diff --git a/dangerzone/gui/__init__.py b/dangerzone/gui/__init__.py index 2e79083..5e94446 100644 --- a/dangerzone/gui/__init__.py +++ b/dangerzone/gui/__init__.py @@ -8,6 +8,7 @@ from PySide2 import QtCore, QtWidgets from .common import GuiCommon from .main_window import MainWindow +from .systray import SysTray from .docker_installer import ( is_docker_installed, is_docker_ready, @@ -149,4 +150,7 @@ def gui_main(custom_container, filename): # If the application is activated and all windows are closed, open a new one app_wrapper.application_activated.connect(application_activated) + # Create a system tray, which also handles the VM subprocess + systray = SysTray(global_common, gui_common, app) + sys.exit(app.exec_()) diff --git a/dangerzone/gui/systray.py b/dangerzone/gui/systray.py new file mode 100644 index 0000000..f1f1bbd --- /dev/null +++ b/dangerzone/gui/systray.py @@ -0,0 +1,29 @@ +from PySide2 import QtCore, QtGui, QtWidgets + + +class SysTray(QtWidgets.QSystemTrayIcon): + def __init__(self, global_common, gui_common, app): + super(SysTray, self).__init__() + self.global_common = global_common + self.gui_common = gui_common + self.app = app + + self.setIcon(self.gui_common.get_window_icon()) + + menu = QtWidgets.QMenu() + self.status_action = menu.addAction("Dangerzone is starting ...") + self.status_action.setEnabled(False) + menu.addSeparator() + self.restart_action = menu.addAction("Restart") + self.restart_action.triggered.connect(self.restart_clicked) + self.quit_action = menu.addAction("Quit") + self.quit_action.triggered.connect(self.quit_clicked) + + self.setContextMenu(menu) + self.show() + + def restart_clicked(self): + self.status_action.setText("Restarting Dangerzone ...") + + def quit_clicked(self): + self.app.quit() diff --git a/install/macos/collect-bins.sh b/install/macos/collect-bins.sh new file mode 100755 index 0000000..ced9403 --- /dev/null +++ b/install/macos/collect-bins.sh @@ -0,0 +1,4 @@ +#!/bin/sh +mkdir -p share/bin +cp /Applications/Docker.app/Contents/Resources/bin/com.docker.hyperkit share/bin/hyperkit +cp /Applications/Docker.app/Contents/Resources/bin/com.docker.vpnkit share/bin/vpnkit diff --git a/install/macos/entitlements.plist b/install/macos/entitlements.plist index 1eeeeaa..f9fbb79 100644 --- a/install/macos/entitlements.plist +++ b/install/macos/entitlements.plist @@ -1,9 +1,12 @@ - - - com.apple.security.cs.allow-unsigned-executable-memory - - + + + com.apple.security.cs.allow-unsigned-executable-memory + + + com.apple.vm.networking + + \ No newline at end of file