|
|
@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
import time
|
|
|
|
import logging
|
|
|
|
import logging
|
|
|
|
|
|
|
|
|
|
|
|
from ubuntu_smoother.utils import checks
|
|
|
|
from ubuntu_smoother.utils import checks
|
|
|
@ -20,59 +22,78 @@ class Configurator:
|
|
|
|
self.__enable_flatpak() if self.config.flatpak else self.__disable_flatpak()
|
|
|
|
self.__enable_flatpak() if self.config.flatpak else self.__disable_flatpak()
|
|
|
|
self.__enable_apport() if self.config.apport else self.__disable_apport()
|
|
|
|
self.__enable_apport() if self.config.apport else self.__disable_apport()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __fake(self, msg: str):
|
|
|
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
logger.info(f"Fake: {msg}")
|
|
|
|
|
|
|
|
|
|
|
|
def __enable_snap(self):
|
|
|
|
def __enable_snap(self):
|
|
|
|
if self.fake:
|
|
|
|
if self.fake:
|
|
|
|
logger.info("Fake: Snap enabled")
|
|
|
|
return self.__fake("Fake: Snap enabled")
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pkgs = []
|
|
|
|
|
|
|
|
if not checks.is_snap_installed():
|
|
|
|
if not checks.is_snap_installed():
|
|
|
|
pkgs += ['snapd', 'gnome-software-plugin-snap']
|
|
|
|
Apt.install(['snapd', 'gnome-software-plugin-snap'])
|
|
|
|
Apt.install(pkgs)
|
|
|
|
Apt.update()
|
|
|
|
Apt.update()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not self.config.flatpak:
|
|
|
|
if not self.config.flatpak:
|
|
|
|
Snap.install(['snap-store'])
|
|
|
|
Snap.install(['snap-store'])
|
|
|
|
|
|
|
|
|
|
|
|
def __disable_snap(self):
|
|
|
|
def __disable_snap(self):
|
|
|
|
if self.fake:
|
|
|
|
if self.fake:
|
|
|
|
logger.info("Fake: Snap disabled")
|
|
|
|
return self.__fake("Fake: Snap disabled")
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if checks.is_snap_installed():
|
|
|
|
if checks.is_snap_installed():
|
|
|
|
Apt.purge(['snapd'])
|
|
|
|
Apt.purge(['snapd'])
|
|
|
|
|
|
|
|
|
|
|
|
def __enable_flatpak(self):
|
|
|
|
def __enable_flatpak(self):
|
|
|
|
if self.fake:
|
|
|
|
if self.fake:
|
|
|
|
logger.info("Fake: Flatpak enabled")
|
|
|
|
return self.__fake("Fake: Flatpak enabled")
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not checks.is_flatpak_installed():
|
|
|
|
if not checks.is_flatpak_installed():
|
|
|
|
Apt.install(['flatpak'])
|
|
|
|
Apt.install(['flatpak'])
|
|
|
|
|
|
|
|
Apt.update()
|
|
|
|
Flatpak.add_repo("https://flathub.org/repo/flathub.flatpakrepo")
|
|
|
|
Flatpak.add_repo("https://flathub.org/repo/flathub.flatpakrepo")
|
|
|
|
Apt.update()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __disable_flatpak(self):
|
|
|
|
def __disable_flatpak(self):
|
|
|
|
if self.fake:
|
|
|
|
if self.fake:
|
|
|
|
logger.info("Fake: Flatpak disabled")
|
|
|
|
return self.__fake("Fake: Flatpak disabled")
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if checks.is_flatpak_installed():
|
|
|
|
if checks.is_flatpak_installed():
|
|
|
|
Apt.purge(['flatpak'])
|
|
|
|
Apt.purge(['flatpak'])
|
|
|
|
|
|
|
|
|
|
|
|
def __enable_apport(self):
|
|
|
|
def __enable_apport(self):
|
|
|
|
if self.fake:
|
|
|
|
if self.fake:
|
|
|
|
logger.info("Fake: Apport enabled")
|
|
|
|
return self.__fake("Fake: Apport enabled")
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not checks.is_apport_installed():
|
|
|
|
if not checks.is_apport_installed():
|
|
|
|
Apt.install(['apport'])
|
|
|
|
Apt.install(['apport'])
|
|
|
|
Apt.update()
|
|
|
|
Apt.update()
|
|
|
|
|
|
|
|
|
|
|
|
def __disable_apport(self):
|
|
|
|
def __disable_apport(self):
|
|
|
|
if self.fake:
|
|
|
|
if self.fake:
|
|
|
|
logger.info("Fake: Apport disabled")
|
|
|
|
return self.__fake("Fake: Apport disabled")
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if checks.is_apport_installed():
|
|
|
|
if checks.is_apport_installed():
|
|
|
|
Apt.purge(['apport'])
|
|
|
|
Apt.purge(['apport'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __disable_on_startup(self):
|
|
|
|
|
|
|
|
if self.fake:
|
|
|
|
|
|
|
|
return self.__fake("Fake: Disable on startup")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
autostart_file = os.path.expanduser("~/.config/autostart/ubuntu-smoother.desktop")
|
|
|
|
|
|
|
|
if os.path.exists(autostart_file):
|
|
|
|
|
|
|
|
os.remove(autostart_file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __enable_on_startup(self):
|
|
|
|
|
|
|
|
if self.fake:
|
|
|
|
|
|
|
|
return self.__fake("Fake: Enable on startup")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
autostart_file = os.path.expanduser("~/.config/autostart/ubuntu-smoother.desktop")
|
|
|
|
|
|
|
|
if not os.path.exists(autostart_file):
|
|
|
|
|
|
|
|
with open(autostart_file, "w") as f:
|
|
|
|
|
|
|
|
f.write("[Desktop Entry]")
|
|
|
|
|
|
|
|
f.write("Type=Application")
|
|
|
|
|
|
|
|
f.write("Name=Ubuntu Smoother")
|
|
|
|
|
|
|
|
f.write("Exec=ubuntu-smoother")
|
|
|
|
|
|
|
|
f.write("Terminal=false")
|
|
|
|
|
|
|
|
f.write("X-GNOME-Autostart-enabled=true")
|
|
|
|
|
|
|
|
|