add distrobox as an option

main
mirkobrombin 2 years ago
parent 65e510e3dd
commit eab9504225

@ -68,6 +68,7 @@
<object class="AdwActionRow">
<property name="title">Snap</property>
<property name="subtitle">Will replace GNOME Software with Snap store if the only package manager.</property>
<property name="activatable-widget">switch_snap</property>
<child>
<object class="GtkSwitch" id="switch_snap">
<property name="valign">center</property>
@ -79,6 +80,7 @@
<object class="AdwActionRow">
<property name="title">Flatpak</property>
<property name="subtitle">Will also configure the Flathub repository.</property>
<property name="activatable-widget">switch_flatpak</property>
<child>
<object class="GtkSwitch" id="switch_flatpak">
<property name="valign">center</property>
@ -95,6 +97,7 @@
<object class="AdwActionRow">
<property name="title">Apport</property>
<property name="subtitle">Do you want to keep the Bug Reporter utility?</property>
<property name="activatable-widget">switch_apport</property>
<child>
<object class="GtkSwitch" id="switch_apport">
<property name="valign">center</property>
@ -102,6 +105,18 @@
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title">Distrobox</property>
<property name="subtitle">Allows you to create containers with different distributions.</property>
<property name="activatable-widget">switch_distrobox</property>
<child>
<object class="GtkSwitch" id="switch_distrobox">
<property name="valign">center</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>

@ -1,25 +1,28 @@
class Config:
def __init__(self, snap: bool, flatpak: bool, apport: bool):
def __init__(self, snap: bool, flatpak: bool, apport: bool, distrobox: bool):
self.snap = snap
self.flatpak = flatpak
self.apport = apport
self.distrobox = distrobox
def get_str(self) -> str:
return "snap::{0}|flatpak::{1}|apport::{2}".format(
self.snap, self.flatpak, self.apport
return "snap::{0}|flatpak::{1}|apport::{2}|distrobox::{3}".format(
self.snap, self.flatpak, self.apport, self.distrobox
)
@classmethod
def from_str(cls, config_str: str) -> 'Config':
items = config_str.split('|')
snap = items[0].split('::')[1]
flatpak = items[1].split('::')[1]
apport = items[2].split('::')[1]
distrobox = items[3].split('::')[1]
return cls(
snap=bool(snap),
flatpak=bool(flatpak),
apport=bool(apport)
apport=bool(apport),
distrobox=bool(distrobox)
)

@ -3,3 +3,4 @@ class Preset:
snap: bool = True
flatpak: bool = True
apport: bool = True
distrobox: bool = True

@ -1,6 +1,7 @@
import os
import time
import logging
import subprocess
from ubuntu_smoother.utils import checks
from ubuntu_smoother.utils.apt import Apt
@ -21,6 +22,8 @@ class Configurator:
self.__enable_snap() if self.config.snap else self.__disable_snap()
self.__enable_flatpak() if self.config.flatpak else self.__disable_flatpak()
self.__enable_apport() if self.config.apport else self.__disable_apport()
if self.config.distrobox:
self.__enable_distrobox()
def __fake(self, msg: str):
time.sleep(1)
@ -74,6 +77,16 @@ class Configurator:
if checks.is_apport_installed():
Apt.purge(['apport'])
def __enable_distrobox(self):
if self.fake:
return self.__fake("Fake: Distrobox enabled")
Apt.install(['curl', 'podman'])
Apt.update()
proc = subprocess.run(['curl', '-s', 'https://raw.githubusercontent.com/89luca89/distrobox/main/install'], stdout=subprocess.PIPE)
proc = subprocess.run(['sudo', 'sh'], input=proc.stdout, stdout=subprocess.PIPE)
def __disable_on_startup(self):
if self.fake:
@ -82,18 +95,3 @@ class Configurator:
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")

@ -33,6 +33,7 @@ class UbuntuSmootherWindow(Adw.ApplicationWindow):
switch_snap = Gtk.Template.Child()
switch_flatpak = Gtk.Template.Child()
switch_apport = Gtk.Template.Child()
switch_distrobox = Gtk.Template.Child()
page_welcome = -1
page_configuration = 0
page_progress = 1
@ -44,7 +45,8 @@ class UbuntuSmootherWindow(Adw.ApplicationWindow):
self.__config = Config(
snap=Preset.snap,
flatpak=Preset.flatpak,
apport=Preset.apport
apport=Preset.apport,
distrobox=Preset.distrobox
)
self.__buiild_ui()
self.__connect_signals()
@ -53,6 +55,7 @@ class UbuntuSmootherWindow(Adw.ApplicationWindow):
self.switch_snap.set_active(Preset.snap)
self.switch_flatpak.set_active(Preset.flatpak)
self.switch_apport.set_active(Preset.apport)
self.switch_distrobox.set_active(Preset.distrobox)
def __connect_signals(self):
self.btn_start.connect('clicked', self.__on_btn_start_clicked)
@ -63,6 +66,8 @@ class UbuntuSmootherWindow(Adw.ApplicationWindow):
'state-set', self.__on_switch_flatpak_state_set)
self.switch_apport.connect(
'state-set', self.__on_switch_apport_state_set)
self.switch_distrobox.connect(
'state-set', self.__on_switch_distrobox_state_set)
def __show_page(self, page: int):
_page = self.carousel.get_nth_page(page + 1)
@ -90,5 +95,8 @@ class UbuntuSmootherWindow(Adw.ApplicationWindow):
def __on_switch_apport_state_set(self, widget, state):
self.__config.apport = state
def __on_switch_distrobox_state_set(self, widget, state):
self.__config.distrobox = state
def on_btn_close_clicked(self, widget):
self.get_application().quit()

Loading…
Cancel
Save