xfce.oy import subprocess def run_command(command, require_sudo=False): """ Runs a system command. """ try: if require_sudo: command = ["sudo"] + command result = subprocess.run(command, check=True, text=True, capture_output=True) print(result.stdout) except subprocess.CalledProcessError as e: print(f"Error: {e.stderr}") return False return True def install_xfce(): """ Installs XFCE desktop environment. """ print("Updating package list...") if not run_command(["apt", "update"], require_sudo=True): return False print("Installing XFCE desktop environment...") if not run_command(["apt", "install", "-y", "xfce4", "xfce4-goodies"], require_sudo=True): return False print("Installation complete.") return True def set_default_display_manager(): """ Configures lightdm as the default display manager. """ print("Setting LightDM as the default display manager...") if not run_command(["apt", "install", "-y", "lightdm", "lightdm-gtk-greeter"], require_sudo=True): return False print("Reconfiguring LightDM...") if not run_command(["dpkg-reconfigure", "lightdm"], require_sudo=True): return False print("Display manager set to LightDM.") return True def reboot_system(): """ Reboots the system. """ print("Rebooting the system to apply changes...") run_command(["reboot"], require_sudo=True) if __name__ == "__main__": print("Starting XFCE upgrade process...") if install_xfce() and set_default_display_manager(): print("XFCE installed successfully. The system will reboot now.") reboot_system() else: print("An error occurred during the upgrade process. Please check the output for details.")