Created
October 24, 2022 13:58
-
-
Save RichardFevrier/5fd665d30b7a76e955dbf38eeace0d13 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env -S python3 -u | |
# -*- coding: utf-8 -*- | |
import subprocess | |
def _main() -> None: | |
installed_fedora_app_ids: list[str] = [] | |
process = subprocess.Popen(['flatpak', 'list', '--columns=application,origin'], stdout=subprocess.PIPE) | |
if process.stdout is None: | |
return | |
for line in process.stdout: | |
values: list[str] = line.decode('utf-8').split() | |
if values[1] == 'fedora': | |
installed_fedora_app_ids.append(values[0]) | |
if len(installed_fedora_app_ids) == 0: | |
return | |
all_flathub_app_ids: list[str] = [] | |
process = subprocess.Popen(['flatpak', 'remote-ls', 'flathub', '--columns=application'], stdout=subprocess.PIPE) | |
if process.stdout is None: | |
return | |
all_flathub_app_ids = process.stdout.read().decode('utf-8').split() | |
if len(all_flathub_app_ids) == 0: | |
return | |
for app_id in installed_fedora_app_ids: | |
if not app_id in all_flathub_app_ids: | |
continue | |
process = subprocess.Popen(['flatpak', 'uninstall', app_id, '--assumeyes']) | |
process.wait() | |
process = subprocess.Popen(['flatpak', 'install', 'flathub', app_id, '--assumeyes']) | |
process.wait() | |
def main() -> None: | |
_main() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment