A tool designed to remove bloatware and restore user freedom
#!/usr/bin/env python3

# SPDX-License-Identifier: GPL-3.0-or-later
#
# This file is part of riddance.
#
# riddance is a tool designed to remove bloatware and restore user freedom.
# Copyright (C) 2023  Rylan Justice <rylanjustice@protonmail.com>
#
# riddance 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, or
# (at your option) any later version.
#
# riddance 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 riddance.  If not, see <https://www.gnu.org/licenses/>.

from .cli import main


if __name__ == '__main__':
    main()

src/riddance/__main__.py
rylan-justice/riddance
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This file is part of riddance.
#
# riddance is a tool designed to remove bloatware and restore user freedom.
# Copyright (C) 2023  Rylan Justice <rylanjustice@protonmail.com>
#
# riddance 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, or
# (at your option) any later version.
#
# riddance 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 riddance.  If not, see <https://www.gnu.org/licenses/>.

import argparse

from rich import print

from .constants import HELP, VERSION
from .utils import os_check, os_list, os_debloat


def main():
    parser = argparse.ArgumentParser(
        prog='riddance',
        add_help=False,
    )
    parser.add_argument(
        '-h',
        '--help',
        action='store_true',
    )
    parser.add_argument(
        '-v',
        '--version',
        action='store_true',
    )
    parser.add_argument(
        '--os-check',
        action='store_true',
    )
    parser.add_argument(
        '--os-list',
        action='store_true',
    )
    parser.add_argument(
        '--os-debloat',
        action='store_true',
    )
    args = parser.parse_args()

    if args.help:
        print(HELP)

    if args.version:
        print(VERSION)

    if args.os_check:
        os_check()

    if args.os_list:
        os_list()

    if args.os_debloat:
        os_debloat()

src/riddance/cli.py
rylan-justice/riddance
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This file is part of riddance.
#
# riddance is a tool designed to remove bloatware and restore user freedom.
# Copyright (C) 2023  Rylan Justice <rylanjustice@protonmail.com>
#
# riddance 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, or
# (at your option) any later version.
#
# riddance 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 riddance.  If not, see <https://www.gnu.org/licenses/>.

HELP = '''[bold]riddance[/bold]

[italic]A tool designed to remove bloatware and restore user freedom[/italic]

usage: riddance [-h] [-v] [--os-check] [--os-list] [--os-debloat]

options:
  -h, --help         display help information
  -v, --version      display riddance version
  --os-check         check if your operating system and version are compatible
  --os-list          list compatible operating system versions
  --os-debloat       debloat your operating system to your preference'''
DEFAULT = '[default]'
VERSION = f'riddance {DEFAULT}1.0.0'
OS_IDENTIFIERS = {
    'Linux': {
        'fedora': ['38 (Workstation Edition)'],
    }
}
BOLD_GREEN = '[bold #41fc7f]'
BOLD_RED = '[bold #fc416a]'

src/riddance/constants.py
rylan-justice/riddance
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This file is part of riddance.
#
# riddance is a tool designed to remove bloatware and restore user freedom.
# Copyright (C) 2023  Rylan Justice <rylanjustice@protonmail.com>
#
# riddance 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, or
# (at your option) any later version.
#
# riddance 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 riddance.  If not, see <https://www.gnu.org/licenses/>.


def fedora_38_ws():
    pass

src/riddance/os.py
rylan-justice/riddance
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This file is part of riddance.
#
# riddance is a tool designed to remove bloatware and restore user freedom.
# Copyright (C) 2023  Rylan Justice <rylanjustice@protonmail.com>
#
# riddance 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, or
# (at your option) any later version.
#
# riddance 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 riddance.  If not, see <https://www.gnu.org/licenses/>.

import platform

from rich import print

from .constants import OS_IDENTIFIERS, BOLD_GREEN, DEFAULT, BOLD_RED
from .os import fedora_38_ws


def os_check():
    os_name = platform.system()
    os_version = platform.version()

    if os_name == 'Linux':
        distro_info = platform.freedesktop_os_release()
        distro_id, distro_version = distro_info.get('ID'), distro_info.get('VERSION')

        if (
            distro_id in OS_IDENTIFIERS['Linux']
            and distro_version in OS_IDENTIFIERS['Linux'][distro_id]
        ):
            print(
                f'{BOLD_GREEN}[ i ][/]  riddance is compatible with [bold]{distro_id.capitalize()} {DEFAULT}{distro_version}'
            )
            return True
        else:
            print(
                f'{BOLD_RED}[ [blink]![/blink] ][/]  riddance is incompatible with [bold]{distro_id.capitalize()} {DEFAULT}{distro_version}'
            )
            return False
    else:
        print(
            f'{BOLD_RED}[ [blink]![/blink] ][/]  riddance is incompatible with [bold]{os_name} {DEFAULT}{os_version}'
        )
        return False


def os_list():
    print(f'{BOLD_GREEN}[ i ][/]  Operating systems compatible with riddance\n')
    for os_names, os_versions in OS_IDENTIFIERS['Linux'].items():
        os_version = ', '.join(os_versions)
        print(f'[bold]{os_names.capitalize()}[/bold] {DEFAULT}{os_version}')


def os_debloat():
    if os_check():
        while True:
            user_input = input('\nWould you like to proceed? [y/n]: ').strip().lower()

            if user_input == 'y':
                if '38 (Workstation Edition)' in OS_IDENTIFIERS['Linux']['fedora']:
                    fedora_38_ws()
            elif user_input == 'n':
                break
            else:
                print(
                    f'\n{BOLD_RED}[ [blink]![/blink] ][/]  Please provide a valid response of {DEFAULT}"[bold]y[/bold]" or "[bold]n[/bold]."'
                )

src/riddance/utils.py
rylan-justice/riddance