bubbles/python_modules/infra_modules/desktop_configs.py

230 lines
8.1 KiB
Python

"""
* SPDX-FileCopyrightText: 2023-2025 PeppermintOS Team
* (peppermintosteam@proton.me)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* This modules contained the functions that will copy the desktop
* configuration files to thier expected locations.
"""
import shutil
from python_modules.logger_modules import builder_logger as logger
from python_modules.paths_modules import (HOME_FOLDER, WPCHROOT)
def xfce_configs():
"""
Copy the xfce files this is the xfce4 configs but also thunar.
This is for the statdard flagship usage.
"""
logger.debug("Starting to copy XFCE configuration files")
src_xfce = '/xfce/xfce4'
des_xfce = '/etc/skel/.config/xfce4'
full_src_xfce = HOME_FOLDER + src_xfce
full_des_xfce = HOME_FOLDER + '/' + WPCHROOT + des_xfce
logger.info("Copying XFCE4 configuration")
logger.info("Source: %s", full_src_xfce)
logger.info("Destination: %s", full_des_xfce)
try:
shutil.copytree(full_src_xfce, full_des_xfce,
dirs_exist_ok=True)
logger.info("Successfully copied XFCE4 configuration to %s",
full_des_xfce)
except FileNotFoundError:
logger.error("XFCE4 source directory not found: %s",
full_src_xfce)
except PermissionError:
logger.error(
"Permission denied when copying XFCE4 configuration to: %s",
full_des_xfce)
except shutil.Error as _:
logger.error(
"Error occurred while copying XFCE4 configuration: %s",
str(_))
src_thunar = '/xfce/Thunar'
des_thunar = '/etc/skel/.config/Thunar'
full_src_thunar = HOME_FOLDER + src_thunar
full_des_thunar = HOME_FOLDER + '/' + WPCHROOT + des_thunar
logger.info("Copying Thunar configuration")
logger.info("Source: %s", full_src_thunar)
logger.info("Destination: %s", full_des_thunar)
try:
shutil.copytree(full_src_thunar, full_des_thunar,
dirs_exist_ok=True)
logger.info("Successfully copied Thunar configuration to %s",
full_des_thunar)
except FileNotFoundError:
logger.error("Thunar source directory not found: %s",
full_src_thunar)
except PermissionError:
logger.error(
"Permission denied when copying Thunar configuration to: %s",
full_des_thunar)
except shutil.Error as _:
logger.error(
"Error occurred while copying Thunar configuration: %s",
str(_))
logger.info("Completed copying XFCE configuration files")
def xfce_loaded_configs():
"""
Copy the loaded xfce files
"""
logger.debug("Starting to copy loaded XFCE configuration files")
src_loaded = '/loaded/xfce'
des_loaded = '/etc/skel/.config/'
full_src_path = HOME_FOLDER + src_loaded
full_des_path = HOME_FOLDER + '/' + WPCHROOT + des_loaded
logger.info("Copying loaded XFCE configuration")
logger.info("Source: %s", full_src_path)
logger.info("Destination: %s", full_des_path)
try:
shutil.copytree(full_src_path, full_des_path,
dirs_exist_ok=True)
logger.info(
"Successfully copied loaded XFCE configuration to %s",
full_des_path)
except FileNotFoundError:
logger.error(
"Loaded XFCE source directory not found: %s",full_src_path)
except PermissionError:
logger.error(
"Permission denied when copying loaded XFCE configuration "
"to: %s", full_des_path)
except shutil.Error as _:
logger.error(
"Error occurred while copying loaded XFCE configuration: %s",
str(_))
logger.info("Completed copying loaded XFCE configuration files")
def gnome_flashback_configs():
"""
Copy the GNOME Flashback configuration files
"""
logger.debug("Starting to copy GNOME Flashback configuration files")
src_gnomef = '/gnome-flashback'
des_gnomef = '/etc/skel/'
full_src_path = HOME_FOLDER + src_gnomef
full_des_path = HOME_FOLDER + '/' + WPCHROOT + des_gnomef
logger.info("Copying GNOME Flashback configuration")
logger.info("Source: %s", full_src_path)
logger.info("Destination: %s", full_des_path)
try:
shutil.copytree(full_src_path, full_des_path,
dirs_exist_ok=True)
logger.info(
"Successfully copied GNOME Flashback configuration to %s",
full_des_path)
except FileNotFoundError:
logger.error(
"GNOME Flashback source directory not found: %s",
full_src_path)
except PermissionError:
logger.error(
"Permission denied when copying GNOME Flashback "
"configuration to: %s", full_des_path)
except shutil.Error as _:
logger.error("Error occurred while copying GNOME Flashback "
"configuration: %s", str(_))
logger.info("Completed copying GNOME Flashback configuration files")
def open_box_configs():
"""
Copy the OpenBox configuration files
"""
logger.debug("Starting to copy OpenBox configuration files")
src_ob = '/openbox'
des_ob = '/etc/skel/'
full_src_path = HOME_FOLDER + src_ob
full_des_path = HOME_FOLDER + '/' + WPCHROOT + des_ob
logger.info("Copying OpenBox configuration")
logger.info("Source: %s", full_src_path)
logger.info("Destination: %s", full_des_path)
try:
shutil.copytree(full_src_path, full_des_path,
dirs_exist_ok=True)
logger.info(
"Successfully copied OpenBox configuration to %s",
full_des_path)
except FileNotFoundError:
logger.error("OpenBox source directory not found: %s",
full_src_path)
except PermissionError:
logger.error(
"Permission denied when copying OpenBox configuration "
"to: %s", full_des_path)
except shutil.Error as _:
logger.error(
"Error occurred while copying OpenBox configuration: %s",
str(_))
logger.info("Completed copying OpenBox configuration files")
def kde_configs():
"""
Copy the KDE configuration files
"""
logger.debug("Starting to copy KDE configuration files")
src_kde = '/kde'
des_kde = '/etc/skel/'
full_src_path = HOME_FOLDER + src_kde
full_des_path = HOME_FOLDER + '/' + WPCHROOT + des_kde
logger.info("Copying KDE configuration")
logger.info("Source: %s", full_src_path)
logger.info("Destination: %s", full_des_path)
try:
shutil.copytree(full_src_path, full_des_path,
dirs_exist_ok=True)
logger.info("Successfully copied KDE configuration to %s",
full_des_path)
except FileNotFoundError:
logger.error("KDE source directory not found: %s",
full_src_path)
except PermissionError:
logger.error("Permission denied when copying KDE "
"configuration to: %s", full_des_path)
except shutil.Error as _:
logger.error(
"Error occurred while copying KDE configuration: %s",
str(_))
logger.info("Completed copying KDE configuration files")
def server_configs():
"""
Copy the server configuration files
"""
logger.debug("Starting to copy server configuration files")
src_server = '/server/configs'
des_server = '/etc/skel/.config/'
full_src_path = HOME_FOLDER + src_server
full_des_path = HOME_FOLDER + '/' + WPCHROOT + des_server
logger.info("Copying server configuration")
logger.info("Source: %s", full_src_path)
logger.info("Destination: %s", full_des_path)
try:
shutil.copytree(full_src_path, full_des_path,
dirs_exist_ok=True)
logger.info("Successfully copied server configuration to %s",
full_des_path)
except FileNotFoundError:
logger.error(
"Server configuration source directory not found: %s",
full_src_path)
except PermissionError:
logger.error(
"Permission denied when copying server configuration to: %s",
full_des_path)
except shutil.Error as _:
logger.error(
"Error occurred while copying server configuration: %s",
str(_))
logger.info("Completed copying server configuration files")