diff --git a/qubesmanager/utils.py b/qubesmanager/utils.py index 44551fb2..dcf8f01b 100644 --- a/qubesmanager/utils.py +++ b/qubesmanager/utils.py @@ -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 @@ -49,6 +52,28 @@ # - 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' + config_file = 'qubes-qube-manager.conf' + 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') + +# Set organization and config diractory at Module level rather than Applications +set_organization() + def is_internal(vm): """checks if the VM is either an AdminVM or has the 'internal' features""" try: