0.0.3 - rebrand
parent
b86c733760
commit
d9cd02a466
@ -1,16 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<component type="desktop">
|
||||
<id>pm.mirko.UbuntuSmoother.desktop</id>
|
||||
<id>io.github.vanilla-os.SugarCubes.desktop</id>
|
||||
<metadata_license>CC0-1.0</metadata_license>
|
||||
<project_license>GPL-3.0-only</project_license>
|
||||
<name translatable="no">Ubuntu Smoother</name>
|
||||
<name translatable="no">Sugar Cubes</name>
|
||||
<summary>Tweak your Ubuntu Vanilla GNOME installation.</summary>
|
||||
<developer_name translatable="no">Mirko Brombin</developer_name>
|
||||
<description>
|
||||
<p>No description</p>
|
||||
</description>
|
||||
<screenshots></screenshots>
|
||||
<translation type="gettext">pm.mirko.UbuntuSmoother</translation>
|
||||
<translation type="gettext">io.github.vanilla-os.SugarCubes</translation>
|
||||
<content_rating type="oars-1.1"/>
|
||||
<recommends>
|
||||
<control>pointing</control>
|
@ -0,0 +1,8 @@
|
||||
[Desktop Entry]
|
||||
Name=Sugar Cubes
|
||||
Exec=sugar-cubes
|
||||
Icon=io.github.vanilla-os.SugarCubes
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=GTK;
|
||||
StartupNotify=true
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schemalist gettext-domain="sugar-cubes">
|
||||
<schema id="io.github.vanilla-os.SugarCubes" path="/pm/mirko/SugarCubes/">
|
||||
</schema>
|
||||
</schemalist>
|
@ -1,8 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Name=Ubuntu Smoother
|
||||
Exec=ubuntu-smoother
|
||||
Icon=pm.mirko.UbuntuSmoother
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=GTK;
|
||||
StartupNotify=true
|
@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schemalist gettext-domain="ubuntu-smoother">
|
||||
<schema id="pm.mirko.UbuntuSmoother" path="/pm/mirko/UbuntuSmoother/">
|
||||
</schema>
|
||||
</schemalist>
|
@ -1,4 +1,4 @@
|
||||
ubuntu-smoother (0.0.2) jammy; urgency=low
|
||||
sugar-cubes (0.0.3) jammy; urgency=low
|
||||
|
||||
* First release
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
dh_update_autotools_config
|
||||
dh_auto_configure
|
||||
dh_auto_build
|
||||
dh_auto_test
|
||||
dh_prep
|
||||
dh_auto_install
|
||||
dh_installdocs
|
||||
dh_installchangelogs
|
||||
dh_installinit
|
||||
dh_installgsettings
|
||||
dh_icons
|
||||
dh_perl
|
||||
dh_link
|
||||
dh_strip_nondeterminism
|
||||
dh_compress
|
||||
dh_fixperms
|
||||
dh_missing
|
||||
dh_strip
|
||||
dh_makeshlibs
|
||||
dh_shlibdeps
|
||||
dh_installdeb
|
||||
dh_gencontrol
|
||||
dh_md5sums
|
||||
dh_builddeb
|
@ -0,0 +1,2 @@
|
||||
misc:Depends=dconf-gsettings-backend | gsettings-backend
|
||||
misc:Pre-Depends=
|
@ -0,0 +1,10 @@
|
||||
Package: sugar-cubes
|
||||
Version: 0.0.1
|
||||
Architecture: amd64
|
||||
Maintainer: Mirko Brombin <send@mirko.pm>
|
||||
Installed-Size: 65
|
||||
Depends: dconf-gsettings-backend | gsettings-backend, python3, python3-gi, libadwaita-1, gir1.2-gtk-4.0, gir1.2-adw-1
|
||||
Section: utils
|
||||
Priority: optional
|
||||
Homepage: https://github.com/mirkobrombin/sugar-cubes/
|
||||
Description: This utility is meant to be used in Ubuntu Vanilla GNOME as a first-setup wizard.
|
@ -0,0 +1,24 @@
|
||||
3f84a85bd8dcb22475ca07a2d69063ac usr/bin/sugar-cubes
|
||||
e53214a91cfee2c537138e64d0d2357e usr/bin/sugar-cubes-processor
|
||||
f62ae2de8dd39b794fa94951db288612 usr/share/appdata/pm.mirko.SugarCubes.appdata.xml
|
||||
572c7ac7342d5e999af8cf5fc99fc7ba usr/share/applications/pm.mirko.SugarCubes.desktop
|
||||
632c1335ca45192e9b887308023c156c usr/share/doc/sugar-cubes/changelog.gz
|
||||
62ed186d7529beecf72bcf7c48b53a76 usr/share/doc/sugar-cubes/copyright
|
||||
3ff815595db45e9dcd137d06f9d8718c usr/share/glib-2.0/schemas/pm.mirko.SugarCubes.gschema.xml
|
||||
a3cd0585c74138a988a7225dd57fc171 usr/share/icons/hicolor/scalable/apps/pm.mirko.SugarCubes.svg
|
||||
a3cd0585c74138a988a7225dd57fc171 usr/share/icons/hicolor/symbolic/apps/pm.mirko.SugarCubes-symbolic.svg
|
||||
75fdbd9173045311c140056e34292035 usr/share/pm.mirko.SugarCubes/sugar-cubes.gresource
|
||||
d41d8cd98f00b204e9800998ecf8427e usr/share/pm.mirko.SugarCubes/sugar_cubes/__init__.py
|
||||
cacabd792fe13148f625e90b1d63e343 usr/share/pm.mirko.SugarCubes/sugar_cubes/main.py
|
||||
d41d8cd98f00b204e9800998ecf8427e usr/share/pm.mirko.SugarCubes/sugar_cubes/models/__init__.py
|
||||
655cc3575fd9547bcc28605a40adecb4 usr/share/pm.mirko.SugarCubes/sugar_cubes/models/config.py
|
||||
19a9c8ef77a0b94b9bd9da204bf619be usr/share/pm.mirko.SugarCubes/sugar_cubes/models/preset.py
|
||||
d41d8cd98f00b204e9800998ecf8427e usr/share/pm.mirko.SugarCubes/sugar_cubes/utils/__init__.py
|
||||
24bb5bd4e6d6262c1b454b3656ab24e0 usr/share/pm.mirko.SugarCubes/sugar_cubes/utils/apt.py
|
||||
4d805e042731d213eb5139530d8aa638 usr/share/pm.mirko.SugarCubes/sugar_cubes/utils/checks.py
|
||||
7823cbc7898533c975d6a44bc5805480 usr/share/pm.mirko.SugarCubes/sugar_cubes/utils/configurator.py
|
||||
d757da1b73916417336840cc67295681 usr/share/pm.mirko.SugarCubes/sugar_cubes/utils/flatpak.py
|
||||
f2595187532f527875795277675234a5 usr/share/pm.mirko.SugarCubes/sugar_cubes/utils/processor.py
|
||||
0ebff648510796f3d38e84739469f97e usr/share/pm.mirko.SugarCubes/sugar_cubes/utils/run_async.py
|
||||
ebbd22d7a8847f604900387b8c9d86a2 usr/share/pm.mirko.SugarCubes/sugar_cubes/utils/snap.py
|
||||
f07c8b3e157f197d2cefd0a89862b3c1 usr/share/pm.mirko.SugarCubes/sugar_cubes/window.py
|
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
# sugar-cubes.in
|
||||
#
|
||||
# Copyright 2022 mirkobrombin
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundationat version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import signal
|
||||
import locale
|
||||
import gettext
|
||||
|
||||
VERSION = '0.0.1'
|
||||
pkgdatadir = '/usr/share/pm.mirko.SugarCubes'
|
||||
localedir = '/usr/share/locale'
|
||||
|
||||
sys.path.insert(1, pkgdatadir)
|
||||
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||
locale.bindtextdomain('sugar_cubes', localedir)
|
||||
locale.textdomain('sugar_cubes')
|
||||
gettext.install('sugar_cubes', localedir)
|
||||
|
||||
if __name__ == '__main__':
|
||||
import gi
|
||||
|
||||
from gi.repository import Gio
|
||||
resource = Gio.Resource.load(os.path.join(pkgdatadir, 'sugar-cubes.gresource'))
|
||||
resource._register()
|
||||
|
||||
from sugar_cubes import main
|
||||
sys.exit(main.main(VERSION))
|
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
# sugar-cubes-processor.in
|
||||
#
|
||||
# Copyright 2022 mirkobrombin
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundationat version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import signal
|
||||
import locale
|
||||
import gettext
|
||||
import argparse
|
||||
|
||||
VERSION = '0.0.1'
|
||||
pkgdatadir = '/usr/share/pm.mirko.SugarCubes'
|
||||
localedir = '/usr/share/locale'
|
||||
|
||||
sys.path.insert(1, pkgdatadir)
|
||||
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||
locale.bindtextdomain('sugar_cubes', localedir)
|
||||
locale.textdomain('sugar_cubes')
|
||||
gettext.install('sugar_cubes', localedir)
|
||||
|
||||
if __name__ == '__main__':
|
||||
from sugar_cubes.utils.configurator import Configurator
|
||||
from sugar_cubes.models.config import Config
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('config', help='The configuration string (e.g. snap::True|flatpak::False|apport::True)')
|
||||
args = parser.parse_args()
|
||||
|
||||
config = Config.from_str(args.config)
|
||||
Configurator(config).apply()
|
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<component type="desktop">
|
||||
<id>pm.mirko.SugarCubes.desktop</id>
|
||||
<metadata_license>CC0-1.0</metadata_license>
|
||||
<project_license>GPL-3.0-only</project_license>
|
||||
<name translatable="no">Sugar Cubes</name>
|
||||
<summary>Tweak your Ubuntu Vanilla GNOME installation.</summary>
|
||||
<developer_name translatable="no">Mirko Brombin</developer_name>
|
||||
<description>
|
||||
<p>No description</p>
|
||||
</description>
|
||||
<screenshots/>
|
||||
<translation type="gettext">pm.mirko.SugarCubes</translation>
|
||||
<content_rating type="oars-1.1"/>
|
||||
<recommends>
|
||||
<control>pointing</control>
|
||||
<control>keyboard</control>
|
||||
<control>touch</control>
|
||||
</recommends>
|
||||
<requires>
|
||||
<display_length compare="ge">768</display_length>
|
||||
</requires>
|
||||
<releases>
|
||||
<release version="1.0.1" date="2022-09-03">
|
||||
<description>
|
||||
<p>First release</p>
|
||||
</description>
|
||||
</release>
|
||||
</releases>
|
||||
</component>
|
@ -0,0 +1,8 @@
|
||||
[Desktop Entry]
|
||||
Name=Sugar Cubes
|
||||
Exec=sugar-cubes
|
||||
Icon=pm.mirko.SugarCubes
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=GTK;
|
||||
StartupNotify=true
|
Binary file not shown.
@ -0,0 +1,23 @@
|
||||
Format: http://dep.debian.net/deps/dep5
|
||||
Upstream-Name: Sugar Cubes
|
||||
Source: https://github.com/mirko-brombin/sugar-cubes
|
||||
|
||||
Files: *
|
||||
Copyright: 2022 Mirko Brombin <send@mirko.pm>
|
||||
License: GPL-3.0
|
||||
|
||||
License: GPL-3.0
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License.
|
||||
.
|
||||
This package is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
.
|
||||
On Debian systems, the complete text of the GNU General
|
||||
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schemalist gettext-domain="sugar-cubes">
|
||||
<schema id="pm.mirko.SugarCubes" path="/pm/mirko/SugarCubes/">
|
||||
</schema>
|
||||
</schemalist>
|
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg">
|
||||
<ellipse style="fill: rgb(221, 72, 20);" cx="250.444" cy="246.003" rx="214.92" ry="214.92"/>
|
||||
<g transform="matrix(1, 0, 0, 1, -119.704704, -266.193634)" id="layer1">
|
||||
<g transform="translate(925.8326,120.8762)" id="g3963">
|
||||
<g transform="matrix(2.269061, 0, 0, 2.269061, -671.41095, 251.059219)" style="fill: black; fill-opacity: 1; fill-rule: nonzero; stroke: none; stroke-miterlimit: 4;" id="g3771">
|
||||
<g style="fill:black;fill-opacity:1" id="g3773">
|
||||
<path d="M 86.068,0 C 61.466,0 56.851,35.041 70.691,35.041 C 84.529,35.041 110.671,0 86.068,0 z " style="fill-opacity: 1; fill: rgb(255, 255, 255);" id="path3775"/>
|
||||
<path d="M 45.217,30.699 C 52.586,31.149 60.671,2.577 46.821,4.374 C 32.976,6.171 37.845,30.249 45.217,30.699 z " style="fill-opacity: 1; fill: rgb(255, 255, 255);" id="path3777"/>
|
||||
<path d="M 11.445,48.453 C 16.686,46.146 12.12,23.581 3.208,29.735 C -5.7,35.89 6.204,50.759 11.445,48.453 z " style="fill-opacity: 1; fill: rgb(255, 255, 255);" id="path3779"/>
|
||||
<path d="M 26.212,36.642 C 32.451,35.37 32.793,9.778 21.667,14.369 C 10.539,18.961 19.978,37.916 26.212,36.642 L 26.212,36.642 z " style="fill-opacity: 1; fill: rgb(255, 255, 255);" id="path3781"/>
|
||||
<path d="M 58.791,93.913 C 59.898,102.367 52.589,106.542 45.431,101.092 C 22.644,83.743 83.16,75.088 79.171,51.386 C 75.86,31.712 15.495,37.769 8.621,68.553 C 3.968,89.374 27.774,118.26 52.614,118.26 C 64.834,118.26 78.929,107.226 81.566,93.248 C 83.58,82.589 57.867,86.86 58.791,93.913 L 58.791,93.913 z " style="fill-opacity: 1; fill: rgb(255, 255, 255);" id="path3783"/>
|
||||
</g>
|
||||
</g>
|
||||
<text x="-406.52405" y="527.92285" style="font-size: 25.8884px; font-style: normal; font-weight: normal; fill: black; fill-opacity: 1; stroke: none; stroke-width: 1pt; stroke-linecap: butt; stroke-linejoin: miter; stroke-opacity: 1; font-family: "Bitstream Vera Sans"; white-space: pre;" id="text3797"> </text>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.0 KiB |
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg">
|
||||
<ellipse style="fill: rgb(221, 72, 20);" cx="250.444" cy="246.003" rx="214.92" ry="214.92"/>
|
||||
<g transform="matrix(1, 0, 0, 1, -119.704704, -266.193634)" id="layer1">
|
||||
<g transform="translate(925.8326,120.8762)" id="g3963">
|
||||
<g transform="matrix(2.269061, 0, 0, 2.269061, -671.41095, 251.059219)" style="fill: black; fill-opacity: 1; fill-rule: nonzero; stroke: none; stroke-miterlimit: 4;" id="g3771">
|
||||
<g style="fill:black;fill-opacity:1" id="g3773">
|
||||
<path d="M 86.068,0 C 61.466,0 56.851,35.041 70.691,35.041 C 84.529,35.041 110.671,0 86.068,0 z " style="fill-opacity: 1; fill: rgb(255, 255, 255);" id="path3775"/>
|
||||
<path d="M 45.217,30.699 C 52.586,31.149 60.671,2.577 46.821,4.374 C 32.976,6.171 37.845,30.249 45.217,30.699 z " style="fill-opacity: 1; fill: rgb(255, 255, 255);" id="path3777"/>
|
||||
<path d="M 11.445,48.453 C 16.686,46.146 12.12,23.581 3.208,29.735 C -5.7,35.89 6.204,50.759 11.445,48.453 z " style="fill-opacity: 1; fill: rgb(255, 255, 255);" id="path3779"/>
|
||||
<path d="M 26.212,36.642 C 32.451,35.37 32.793,9.778 21.667,14.369 C 10.539,18.961 19.978,37.916 26.212,36.642 L 26.212,36.642 z " style="fill-opacity: 1; fill: rgb(255, 255, 255);" id="path3781"/>
|
||||
<path d="M 58.791,93.913 C 59.898,102.367 52.589,106.542 45.431,101.092 C 22.644,83.743 83.16,75.088 79.171,51.386 C 75.86,31.712 15.495,37.769 8.621,68.553 C 3.968,89.374 27.774,118.26 52.614,118.26 C 64.834,118.26 78.929,107.226 81.566,93.248 C 83.58,82.589 57.867,86.86 58.791,93.913 L 58.791,93.913 z " style="fill-opacity: 1; fill: rgb(255, 255, 255);" id="path3783"/>
|
||||
</g>
|
||||
</g>
|
||||
<text x="-406.52405" y="527.92285" style="font-size: 25.8884px; font-style: normal; font-weight: normal; fill: black; fill-opacity: 1; stroke: none; stroke-width: 1pt; stroke-linecap: butt; stroke-linejoin: miter; stroke-opacity: 1; font-family: "Bitstream Vera Sans"; white-space: pre;" id="text3797"> </text>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
@ -0,0 +1,72 @@
|
||||
# main.py
|
||||
#
|
||||
# Copyright 2022 mirkobrombin
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundationat version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from sugar_cubes.window import SugarCubesWindow
|
||||
from gi.repository import Gtk, Gio, Adw
|
||||
import sys
|
||||
import gi
|
||||
import logging
|
||||
|
||||
gi.require_version('Gtk', '4.0')
|
||||
gi.require_version('Adw', '1')
|
||||
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
class SugarCubesApplication(Adw.Application):
|
||||
"""The main application singleton class."""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(application_id='pm.mirko.SugarCubes',
|
||||
flags=Gio.ApplicationFlags.FLAGS_NONE)
|
||||
self.create_action('quit', self.close, ['<primary>q'])
|
||||
|
||||
def do_activate(self):
|
||||
"""Called when the application is activated.
|
||||
|
||||
We raise the application's main window, creating it if
|
||||
necessary.
|
||||
"""
|
||||
win = self.props.active_window
|
||||
if not win:
|
||||
win = SugarCubesWindow(application=self)
|
||||
win.present()
|
||||
|
||||
def create_action(self, name, callback, shortcuts=None):
|
||||
"""Add an application action.
|
||||
|
||||
Args:
|
||||
name: the name of the action
|
||||
callback: the function to be called when the action is
|
||||
activated
|
||||
shortcuts: an optional list of accelerators
|
||||
"""
|
||||
action = Gio.SimpleAction.new(name, None)
|
||||
action.connect("activate", callback)
|
||||
self.add_action(action)
|
||||
if shortcuts:
|
||||
self.set_accels_for_action(f"app.{name}", shortcuts)
|
||||
|
||||
def close(self, *args):
|
||||
"""Close the application."""
|
||||
self.quit()
|
||||
|
||||
|
||||
def main(version):
|
||||
"""The application's entry point."""
|
||||
app = SugarCubesApplication()
|
||||
return app.run(sys.argv)
|
@ -0,0 +1,25 @@
|
||||
class Config:
|
||||
|
||||
def __init__(self, snap: bool, flatpak: bool, apport: bool):
|
||||
self.snap = snap
|
||||
self.flatpak = flatpak
|
||||
self.apport = apport
|
||||
|
||||
def get_str(self) -> str:
|
||||
return "snap::{0}|flatpak::{1}|apport::{2}".format(
|
||||
self.snap, self.flatpak, self.apport
|
||||
)
|
||||
|
||||
@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]
|
||||
|
||||
return cls(
|
||||
snap=bool(snap),
|
||||
flatpak=bool(flatpak),
|
||||
apport=bool(apport)
|
||||
)
|
@ -0,0 +1,5 @@
|
||||
class Preset:
|
||||
|
||||
snap: bool = True
|
||||
flatpak: bool = True
|
||||
apport: bool = True
|
@ -0,0 +1,44 @@
|
||||
import subprocess
|
||||
|
||||
|
||||
class Apt:
|
||||
|
||||
@staticmethod
|
||||
def install(packages: list):
|
||||
subprocess.run(
|
||||
['sudo', 'apt', 'install'] + packages,
|
||||
env={'DEBIAN_FRONTEND': 'noninteractive'},
|
||||
check=True
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def remove(packages: list):
|
||||
subprocess.run(
|
||||
['sudo', 'apt', 'remove'] + packages,
|
||||
env={'DEBIAN_FRONTEND': 'noninteractive'},
|
||||
check=True
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def purge(packages: list):
|
||||
subprocess.run(
|
||||
['sudo', 'apt', 'purge'] + packages,
|
||||
env={'DEBIAN_FRONTEND': 'noninteractive'},
|
||||
check=True
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def update():
|
||||
subprocess.run(
|
||||
['sudo', 'apt', 'update'],
|
||||
env={'DEBIAN_FRONTEND': 'noninteractive'},
|
||||
check=True
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def upgrade():
|
||||
subprocess.run(
|
||||
['sudo', 'apt', 'upgrade'],
|
||||
env={'DEBIAN_FRONTEND': 'noninteractive'},
|
||||
check=True
|
||||
)
|
@ -0,0 +1,13 @@
|
||||
import shutil
|
||||
|
||||
|
||||
def is_snap_installed():
|
||||
return shutil.which('snap') is not None
|
||||
|
||||
|
||||
def is_flatpak_installed():
|
||||
return shutil.which('flatpak') is not None
|
||||
|
||||
|
||||
def is_apport_installed():
|
||||
return shutil.which('apport') is not None
|
@ -0,0 +1,99 @@
|
||||
import os
|
||||
import time
|
||||
import logging
|
||||
|
||||
from sugar_cubes.utils import checks
|
||||
from sugar_cubes.utils.apt import Apt
|
||||
from sugar_cubes.utils.flatpak import Flatpak
|
||||
from sugar_cubes.utils.snap import Snap
|
||||
|
||||
|
||||
logger = logging.getLogger("SugarCubes::Configurator")
|
||||
|
||||
|
||||
class Configurator:
|
||||
|
||||
def __init__(self, config: 'Config', fake: bool = False):
|
||||
self.config = config
|
||||
self.fake = fake
|
||||
|
||||
def apply(self):
|
||||
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()
|
||||
|
||||
def __fake(self, msg: str):
|
||||
time.sleep(1)
|
||||
logger.info(f"Fake: {msg}")
|
||||
|
||||
def __enable_snap(self):
|
||||
if self.fake:
|
||||
return self.__fake("Fake: Snap enabled")
|
||||
|
||||
if not checks.is_snap_installed():
|
||||
Apt.install(['snapd', 'gnome-software-plugin-snap'])
|
||||
Apt.update()
|
||||
|
||||
if not self.config.flatpak:
|
||||
Snap.install(['snap-store'])
|
||||
|
||||
def __disable_snap(self):
|
||||
if self.fake:
|
||||
return self.__fake("Fake: Snap disabled")
|
||||
|
||||
if checks.is_snap_installed():
|
||||
Apt.purge(['snapd'])
|
||||
|
||||
def __enable_flatpak(self):
|
||||
if self.fake:
|
||||
return self.__fake("Fake: Flatpak enabled")
|
||||
|
||||
if not checks.is_flatpak_installed():
|
||||
Apt.install(['flatpak'])
|
||||
Apt.update()
|
||||
Flatpak.add_repo("https://flathub.org/repo/flathub.flatpakrepo")
|
||||
|
||||
def __disable_flatpak(self):
|
||||
if self.fake:
|
||||
return self.__fake("Fake: Flatpak disabled")
|
||||
|
||||
if checks.is_flatpak_installed():
|
||||
Apt.purge(['flatpak'])
|
||||
|
||||
def __enable_apport(self):
|
||||
if self.fake:
|
||||
return self.__fake("Fake: Apport enabled")
|
||||
|
||||
if not checks.is_apport_installed():
|
||||
Apt.install(['apport'])
|
||||
Apt.update()
|
||||
|
||||
def __disable_apport(self):
|
||||
if self.fake:
|
||||
return self.__fake("Fake: Apport disabled")
|
||||
|
||||
if checks.is_apport_installed():
|
||||
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/sugar-cubes.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/sugar-cubes.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=Sugar Cubes")
|
||||
f.write("Exec=sugar-cubes")
|
||||
f.write("Terminal=false")
|
||||
f.write("X-GNOME-Autostart-enabled=true")
|
||||
|
@ -0,0 +1,25 @@
|
||||
import subprocess
|
||||
|
||||
|
||||
class Flatpak:
|
||||
|
||||
@staticmethod
|
||||
def install(packages: list):
|
||||
subprocess.run(
|
||||
['flatpak', 'install', '--user'] + packages,
|
||||
check=True
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def remove(packages: list):
|
||||
subprocess.run(
|
||||
['flatpak', 'remove', '--user'] + packages,
|
||||
check=True
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def add_repo(repo: str):
|
||||
subprocess.run(
|
||||
['flatpak', 'remote-add', '--user', '--if-not-exists', repo],
|
||||
check=True
|
||||
)
|
@ -0,0 +1,18 @@
|
||||
import subprocess
|
||||
|
||||
|
||||
class Processor:
|
||||
|
||||
def __init__(self, config: 'Config'):
|
||||
self.__config = config
|
||||
|
||||
def run(self):
|
||||
proc = subprocess.run(
|
||||
["pkexec", "sugar-cubes-processor", self.__config.get_str()],
|
||||
check=True
|
||||
)
|
||||
|
||||
if proc.returncode != 0:
|
||||
return False, "Error executing the Sugar Cubes Processor"
|
||||
|
||||
return True
|
@ -0,0 +1,70 @@
|
||||
# run_async.py
|
||||
#
|
||||
# Copyright 2022 brombinmirko <send@mirko.pm>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, in version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
import os
|
||||
import sys
|
||||
import threading
|
||||
import traceback
|
||||
import logging
|
||||
|
||||
from gi.repository import GLib
|
||||
|
||||
logger = logging.getLogger("SugarCubes::Async")
|
||||
|
||||
|
||||
class RunAsync(threading.Thread):
|
||||
"""
|
||||
This class is used to execute a function asynchronously.
|
||||
It takes a function, a callback and a list of arguments as input.
|
||||
"""
|
||||
|
||||
def __init__(self, task_func, callback=None, *args, **kwargs):
|
||||
if "DEBUG_MODE" in os.environ:
|
||||
import faulthandler
|
||||
faulthandler.enable()
|
||||
|
||||
self.source_id = None
|
||||
assert threading.current_thread() is threading.main_thread()
|
||||
|
||||
super(RunAsync, self).__init__(target=self.__target, args=args, kwargs=kwargs)
|
||||
|
||||
self.task_func = task_func
|
||||
|
||||
self.callback = callback if callback else lambda r, e: None
|
||||
self.daemon = kwargs.pop("daemon", True)
|
||||
|
||||
self.start()
|
||||
|
||||
def __target(self, *args, **kwargs):
|
||||
result = None
|
||||
error = None
|
||||
|
||||
logger.debug(f"Running async job [{self.task_func}].")
|
||||
|
||||
try:
|
||||
result = self.task_func(*args, **kwargs)
|
||||
except Exception as exception:
|
||||
logger.error("Error while running async job: "
|
||||
f"{self.task_func}\nException: {exception}")
|
||||
|
||||
error = exception
|
||||
_ex_type, _ex_value, trace = sys.exc_info()
|
||||
traceback.print_tb(trace)
|
||||
traceback_info = '\n'.join(traceback.format_tb(trace))
|
||||
|
||||
self.source_id = GLib.idle_add(self.callback, result, error)
|
||||
return self.source_id
|
@ -0,0 +1,18 @@
|
||||
import subprocess
|
||||
|
||||
|
||||
class Snap:
|
||||
|
||||
@staticmethod
|
||||
def install(packages: list):
|
||||
subprocess.run(
|
||||
['snap', 'install'] + packages,
|
||||
check=True
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def remove(packages: list):
|
||||
subprocess.run(
|
||||
['snap', 'remove'] + packages,
|
||||
check=True
|
||||
)
|
@ -0,0 +1,94 @@
|
||||
# window.py
|
||||
#
|
||||
# Copyright 2022 mirkobrombin
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundationat version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from gi.repository import Gtk, Gio, Adw
|
||||
|
||||
from sugar_cubes.models.preset import Preset
|
||||
from sugar_cubes.models.config import Config
|
||||
from sugar_cubes.utils.processor import Processor
|
||||
from sugar_cubes.utils.run_async import RunAsync
|
||||
|
||||
|
||||
@Gtk.Template(resource_path='/pm/mirko/SugarCubes/gtk/window.ui')
|
||||
class SugarCubesWindow(Adw.ApplicationWindow):
|
||||
__gtype_name__ = 'SugarCubesWindow'
|
||||
|
||||
carousel = Gtk.Template.Child()
|
||||
btn_start = Gtk.Template.Child()
|
||||
btn_save = Gtk.Template.Child()
|
||||
btn_close = Gtk.Template.Child()
|
||||
switch_snap = Gtk.Template.Child()
|
||||
switch_flatpak = Gtk.Template.Child()
|
||||
switch_apport = Gtk.Template.Child()
|
||||
page_welcome = -1
|
||||
page_configuration = 0
|
||||
page_progress = 1
|
||||
page_done = 2
|
||||
spinner = Gtk.Template.Child()
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.__config = Config(
|
||||
snap=Preset.snap,
|
||||
flatpak=Preset.flatpak,
|
||||
apport=Preset.apport
|
||||
)
|
||||
self.__buiild_ui()
|
||||
self.__connect_signals()
|
||||
|
||||
def __buiild_ui(self):
|
||||
self.switch_snap.set_active(Preset.snap)
|
||||
self.switch_flatpak.set_active(Preset.flatpak)
|
||||
self.switch_apport.set_active(Preset.apport)
|
||||
|
||||
def __connect_signals(self):
|
||||
self.btn_start.connect('clicked', self.__on_btn_start_clicked)
|
||||
self.btn_save.connect('clicked', self.on_btn_save_clicked)
|
||||
self.btn_close.connect('clicked', self.on_btn_close_clicked)
|
||||
self.switch_snap.connect('state-set', self.__on_switch_snap_state_set)
|
||||
self.switch_flatpak.connect(
|
||||
'state-set', self.__on_switch_flatpak_state_set)
|
||||
self.switch_apport.connect(
|
||||
'state-set', self.__on_switch_apport_state_set)
|
||||
|
||||
def __show_page(self, page: int):
|
||||
_page = self.carousel.get_nth_page(page + 1)
|
||||
self.carousel.scroll_to(_page, True)
|
||||
|
||||
def __on_btn_start_clicked(self, widget):
|
||||
self.__show_page(self.page_configuration)
|
||||
|
||||
def on_btn_save_clicked(self, widget):
|
||||
def on_done(result, error=None):
|
||||
self.spinner.stop()
|
||||
self.__show_page(self.page_done)
|
||||
|
||||
self.__show_page(self.page_progress)
|
||||
self.spinner.start()
|
||||
|
||||
RunAsync(Processor(self.__config).run, on_done)
|
||||
|
||||
def __on_switch_snap_state_set(self, widget, state):
|
||||
self.__config.snap = state
|
||||
|
||||
def __on_switch_flatpak_state_set(self, widget, state):
|
||||
self.__config.flatpak = state
|
||||
|
||||
def __on_switch_apport_state_set(self, widget, state):
|
||||
self.__config.apport = state
|
||||
|
||||
def on_btn_close_clicked(self, widget):
|
||||
self.get_application().quit()
|
@ -1 +1 @@
|
||||
i18n.gettext('ubuntu-smoother', preset: 'glib')
|
||||
i18n.gettext('sugar-cubes', preset: 'glib')
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/pm/mirko/UbuntuSmoother">
|
||||
<gresource prefix="/pm/mirko/SugarCubes">
|
||||
<file>gtk/window.ui</file>
|
||||
</gresource>
|
||||
</gresources>
|
Loading…
Reference in New Issue