Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify qubes-os XDG config directory #375

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions qubesmanager/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
import qasync
from qubesadmin import events
from qubesadmin import exc
import xdg.BaseDirectory
import pathlib
import shutil

from PyQt5 import QtWidgets, QtCore, QtGui # pylint: disable=import-error

Expand All @@ -49,6 +52,25 @@
# - just a list, no properties or defaults, just a nice list with a "current"
# value - initialize_widget

def set_organization():
"""set the organization and config home directory for Qt based Apps."""
# migrate old config file to the unified config directory
# TODO: remove the below block when Qubes R4.3 becomes End-of-Life
old_config_home = xdg.BaseDirectory.xdg_config_home + \
'/The Qubes Project'
new_config_home = xdg.BaseDirectory.xdg_config_home + '/qubes-os'
alimirjamali marked this conversation as resolved.
Show resolved Hide resolved
config_file = 'qubes-qube-manager.conf'
alimirjamali marked this conversation as resolved.
Show resolved Hide resolved
old_config_file = old_config_home + '/' + config_file
new_config_file = new_config_home + '/' + config_file
if os.path.isfile(old_config_file) and \
not os.path.isfile(new_config_file):
pathlib.Path(new_config_home).mkdir(parents=True, exist_ok=True)
shutil.copy(old_config_file, new_config_file)

QtCore.QCoreApplication.setOrganizationName('qubes-os')
QtCore.QCoreApplication.setOrganizationDomain('qubes-os.org')
QtCore.QCoreApplication.setApplicationName('qubes-qube-manager')

def is_internal(vm):
"""checks if the VM is either an AdminVM or has the 'internal' features"""
try:
Expand Down Expand Up @@ -497,6 +519,7 @@ def handle_exception(exc_type, exc_value, exc_traceback):


def run_asynchronous(window_class):
set_organization()
qt_app = QtWidgets.QApplication(sys.argv)

translator = QtCore.QTranslator(qt_app)
Expand All @@ -508,8 +531,6 @@ def run_asynchronous(window_class):
qt_app.installTranslator(translator)
QtCore.QCoreApplication.installTranslator(translator)

qt_app.setOrganizationName("The Qubes Project")
qt_app.setOrganizationDomain("http://qubes-os.org")
qt_app.lastWindowClosed.connect(loop_shutdown)

qubes_app = qubesadmin.Qubes()
Expand Down Expand Up @@ -537,6 +558,7 @@ def run_asynchronous(window_class):


def run_synchronous(window_class):
set_organization()
qt_app = QtWidgets.QApplication(sys.argv)

translator = QtCore.QTranslator(qt_app)
Expand All @@ -548,9 +570,6 @@ def run_synchronous(window_class):
qt_app.installTranslator(translator)
QtCore.QCoreApplication.installTranslator(translator)

qt_app.setOrganizationName("The Qubes Project")
qt_app.setOrganizationDomain("http://qubes-os.org")

sys.excepthook = handle_exception

qubes_app = qubesadmin.Qubes()
Expand Down