#1302·thorium

Interactive TUI / CLI THORIUM BROWSER AVX2 MANAGER & (rpm package) UPDATER for Fedora 44 OS ; for x86-64 AVX2 CPU

Author: universishCreated Oct 1, 2026Updated Oct 2, 2026

Interactive TUI / CLI THORIUM BROWSER AVX2 MANAGER & Automated UPDATER

(rpm package only) for Fedora 44 OS ; for x86-64 AVX2 CPU

It is configured as a full-featured console application (TUI/CLI application) that uses Fedora's native Python 3 infrastructure. The entire interface, logs, and menus are designed in English.


System Architecture

  • Application: /usr/local/bin/thorium-manager (Standalone Python 3 software with no external library dependencies).
  • Configuration File: /etc/thorium-manager.json (permanently stores the interactive or unattended operating mode).
  • Timer: /etc/systemd/system/thorium-manager.timer (runs daily at 4:30 PM).
  • Permissions Management: The installation script prevents password prompt lockouts during daily background tasks by adding the /etc/sudoers.d/thorium-manager rule; the TUI will only ask for your password once when it starts.

Step 1: Create the Python Script

Paste the following command into the terminal to save the script as /tmp/thorium-manager (since a single ‘EOF’ block is used, there will be no Bash expansion or quoting errors):

bash
cat << 'EOF' > /tmp/thorium-manager
#!/usr/bin/env python3
"""
Thorium Browser AVX2 Manager & Automated Updater
Author: System Automation
Architecture: x86_64 AVX2 Only
Package: rpm Only
"""

import os
import sys
import json
import re
import shutil
import subprocess
import urllib.request
import pwd
from datetime import datetime

CONFIG_PATH = "/etc/thorium-manager.json"
DEFAULT_USER = "macellan"
TEMP_DIR = "/tmp/thorium_updater"
REPOS = ["Alex313031/Thorium", "gz83/thorium"]

DESKTOP_ENTRY_CONTENT = """[Desktop Entry]
Version=1.0
Name=Thorium Browser
GenericName=Web Browser
GenericName[bg]=Уеб браузър
GenericName[ca]=Navegador web
GenericName[cs]=WWW prohlížeč
GenericName[da]=Browser
GenericName[de]=Web-Browser
GenericName[el]=Περιηγητής ιστού
GenericName[en_GB]=Web Browser
GenericName[es]=Navegador web
GenericName[et]=Veebibrauser
GenericName[fi]=WWW-selain
GenericName[fr]=Navigateur Web
GenericName[gu]=વેબ બ્રાઉઝર
GenericName[hi]=वेब ब्राउज़र
GenericName[hu]=Webböngésző
GenericName[it]=Browser Web
GenericName[ja]=ウェブブラウザ
GenericName[kn]=ಜಾಲ ವೀಕ್ಷಕ
GenericName[ko]=웹 브라우저
GenericName[lt]=Žiniatinklio naršyklė
GenericName[lv]=Tīmekļa pārlūks
GenericName[ml]=വെബ് ബ്രൌസര്‍
GenericName[mr]=वेब ब्राऊजर
GenericName[nb]=Nettleser
GenericName[nl]=Webbrowser
GenericName[pl]=Przeglądarka WWW
GenericName[pt]=Navegador Web
GenericName[pt_BR]=Navegador da Internet
GenericName[ro]=Navigator de Internet
GenericName[ru]=Веб-браузер
GenericName[sl]=Spletni brskalnik
GenericName[sv]=Webbläsare
GenericName[ta]=இணைய உலாவி
GenericName[th]=เว็บเบราว์เซอร์
GenericName[tr]=Web Tarayıcı
GenericName[uk]=Навігатор Тенет
GenericName[zh_CN]=网页浏览器
GenericName[zh_HK]=網頁瀏覽器
GenericName[zh_TW]=網頁瀏覽器
GenericName[bn]=ওয়েব ব্রাউজার
GenericName[fil]=Web Browser
GenericName[hr]=Web preglednik
GenericName[id]=Browser Web
GenericName[or]=ଓ୍ବେବ ବ୍ରାଉଜର
GenericName[sk]=WWW prehliadač
GenericName[sr]=Интернет прегледник
GenericName[te]=మహాతల అన్వేషి
GenericName[vi]=Bộ duyệt Web
Comment=Access the Internet
Comment[bg]=Достъп до интернет
Comment[bn]=ইন্টারনেটটি অ্যাক্সেস করুন
Comment[ca]=Accedeix a Internet
Comment[cs]=Přístup k internetu
Comment[da]=Få adgang til internettet
Comment[de]=Internetzugriff
Comment[el]=Πρόσβαση στο Διαδίκτυο
Comment[en_GB]=Access the Internet
Comment[es]=Accede a Internet.
Comment[et]=Pääs Internetti
Comment[fi]=Käytä internetiä
Comment[fil]=I-access ang Internet
Comment[fr]=Accéder à Internet
Comment[gu]=ઇંટરનેટ ઍક્સેસ કરો
Comment[hi]=इंटरनेट तक पहुंच स्थापित करें
Comment[hr]=Pristup Internetu
Comment[hu]=Internetelérés
Comment[id]=Akses Internet
Comment[it]=Accesso a Internet
Comment[ja]=インターネットにアクセス
Comment[kn]=ಇಂಟರ್ನೆಟ್ ಅನ್ನು ಪ್ರವೇಶಿಸಿ
Comment[ko]=인터넷 연결
Comment[lt]=Interneto prieiga
Comment[lv]=Piekļūt internetam
Comment[ml]=ഇന്റര്‍‌നെറ്റ് ആക്സസ് ചെയ്യുക
Comment[mr]=इंटरनेटमध्ये प्रवेश करा
Comment[nb]=Gå til Internett
Comment[nl]=Verbinding maken met internet
Comment[or]=ଇଣ୍ଟର୍ନେଟ୍ ପ୍ରବେଶ କରନ୍ତୁ
Comment[pl]=Skorzystaj z internetu
Comment[pt]=Aceder à Internet
Comment[pt_BR]=Acessar a internet
Comment[ro]=Accesaţi Internetul
Comment[ru]=Доступ в Интернет
Comment[sk]=Prístup do siete Internet
Comment[sl]=Dostop do interneta
Comment[sr]=Приступите Интернету
Comment[sv]=Gå ut på Internet
Comment[ta]=இணையத்தை அணுகுதல்
Comment[te]=ఇంటర్నెట్‌ను ఆక్సెస్ చెయ్యండి
Comment[th]=เข้าถึงอินเทอร์เน็ต
Comment[tr]=İnternet'e erişin
Comment[uk]=Доступ до Інтернету
Comment[vi]=Truy cập Internet
Comment[zh_CN]=访问互联网
Comment[zh_HK]=連線到網際網路
Comment[zh_TW]=連線到網際網路
Exec=/usr/bin/thorium-browser --ozone-platform=wayland --disable-vulkan --disable-features=Vulkan,UseChromeOSDirectVideoDecoder,WebGPU --enable-features=VaapiVideoDecodeLinuxGL,VaapiVideoEncoder,VaapiIgnoreDriverChecks,CanvasOopRasterization --ignore-gpu-blocklist --enable-zero-copy --enable-gpu-rasterization %U
Keywords=browser
StartupNotify=true
StartupWMClass=thorium-browser
Terminal=false
X-MultipleArgs=true
Icon=thorium-browser
Type=Application
Categories=Network;WebBrowser;
MimeType=application/pdf;application/rdf+xml;application/rss+xml;application/xhtml+xml;application/xhtml_xml;application/xml;image/gif;image/jpeg;image/png;image/webp;text/html;text/xml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;
Actions=new-window;new-private-window;temp-profile;content-shell;safe-mode;dark-mode;

[Desktop Action new-window]
Name=New Window
Exec=/usr/bin/thorium-browser --ozone-platform=wayland --disable-vulkan --disable-features=Vulkan,UseChromeOSDirectVideoDecoder,WebGPU --enable-features=VaapiVideoDecodeLinuxGL,VaapiVideoEncoder,VaapiIgnoreDriverChecks,CanvasOopRasterization --ignore-gpu-blocklist --enable-zero-copy --enable-gpu-rasterization

[Desktop Action new-private-window]
Name=New Incognito Window
Exec=/usr/bin/thorium-browser --ozone-platform=wayland --disable-vulkan --disable-features=Vulkan,UseChromeOSDirectVideoDecoder,WebGPU --enable-features=VaapiVideoDecodeLinuxGL,VaapiVideoEncoder,VaapiIgnoreDriverChecks,CanvasOopRasterization --ignore-gpu-blocklist --enable-zero-copy --enable-gpu-rasterization --incognito %U

[Desktop Action temp-profile]
Name=Open New Window with a temporary profile
Exec=/usr/bin/thorium-browser --ozone-platform=wayland --disable-vulkan --disable-features=Vulkan,UseChromeOSDirectVideoDecoder,WebGPU --enable-features=VaapiVideoDecodeLinuxGL,VaapiVideoEncoder,VaapiIgnoreDriverChecks,CanvasOopRasterization --ignore-gpu-blocklist --enable-zero-copy --enable-gpu-rasterization --temp-profile %U

[Desktop Action content-shell]
Name=Open Thorium Shell
Exec=/usr/bin/thorium--shell %U

[Desktop Action safe-mode]
Name=Open in Safe Mode
Exec=/usr/bin/thorium-browser --ozone-platform=wayland --disable-vulkan --disable-features=Vulkan,UseChromeOSDirectVideoDecoder,WebGPU --enable-features=VaapiVideoDecodeLinuxGL,VaapiVideoEncoder,VaapiIgnoreDriverChecks,CanvasOopRasterization --ignore-gpu-blocklist --enable-zero-copy --enable-gpu-rasterization --no-experiments %U

[Desktop Action dark-mode]
Name=Open in Dark Mode
Exec=/usr/bin/thorium-browser --ozone-platform=wayland --disable-vulkan --disable-features=Vulkan,UseChromeOSDirectVideoDecoder,WebGPU --enable-features=VaapiVideoDecodeLinuxGL,VaapiVideoEncoder,VaapiIgnoreDriverChecks,CanvasOopRasterization --ignore-gpu-blocklist --enable-zero-copy --enable-gpu-rasterization --force-dark-mode %U
"""

class Colors:
    RED = "\033[0;31m"
    GREEN = "\033[0;32m"
    YELLOW = "\033[1;33m"
    CYAN = "\033[0;36m"
    BOLD = "\033[1m"
    NC = "\033[0m"

def log_ok(msg):
    print(f"  [{Colors.GREEN}✓{Colors.NC}] {msg}")

def log_info(msg):
    print(f"  [{Colors.CYAN}i{Colors.NC}] {msg}")

def log_warn(msg):
    print(f"  [{Colors.YELLOW}!{Colors.NC}] {msg}")

def log_err(msg):
    print(f"  [{Colors.RED}✗{Colors.NC}] {msg}")

def ensure_root():
    if os.geteuid() != 0:
        print(f"{Colors.YELLOW}Root privileges required. Re-launching with sudo...{Colors.NC}")
        args = ["sudo", sys.executable] + sys.argv
        os.execvp("sudo", args)

def load_config():
    if os.path.exists(CONFIG_PATH):
        try:
            with open(CONFIG_PATH, "r", encoding="utf-8") as f:
                return json.load(f)
        except Exception:
            pass
    return {
        "mode": "interactive",
        "target_user": DEFAULT_USER,
        "schedule_time": "16:30"
    }

def save_config(cfg):
    try:
        os.makedirs(os.path.dirname(CONFIG_PATH), exist_ok=True)
        with open(CONFIG_PATH, "w", encoding="utf-8") as f:
            json.dump(cfg, f, indent=4)
        return True
    except Exception as e:
        log_err(f"Failed to save configuration: {e}")
        return False

def get_installed_version():
    try:
        res = subprocess.run(["rpm", "-q", "--qf", "%{VERSION}", "thorium-browser"],
                             capture_output=True, text=True, check=False)
        if res.returncode == 0 and res.stdout.strip():
            return res.stdout.strip()
    except Exception:
        pass
    return None

def find_latest_avx2_rpm():
    latest_date = None
    best_candidate = None

    headers = {"User-Agent": "ThoriumManager-Python"}
    for repo in REPOS:
        url = f"https://api.github.com/repos/{repo}/releases?per_page=5"
        try:
            req = urllib.request.Request(url, headers=headers)
            with urllib.request.urlopen(req, timeout=12) as resp:
                data = json.loads(resp.read().decode("utf-8"))
        except Exception as e:
            continue

        for rel in data:
            pub_at = rel.get("published_at", "")
            assets = rel.get("assets", [])
            tag = rel.get("tag_name", "").lstrip("Mv")

            for asset in assets:
                name = asset.get("name", "")
                download_url = asset.get("browser_download_url", "")
                if (re.search(r"avx2", name, re.IGNORECASE) and 
                    name.endswith(".rpm") and 
                    not name.endswith(".src.rpm")):
                    
                    if latest_date is None or pub_at > latest_date:
                        latest_date = pub_at
                        clean_ver_match = re.search(r"[0-9]+(\.[0-9]+)+", tag)
                        clean_ver = clean_ver_match.group(0) if clean_ver_match else tag
                        best_candidate = {
                            "repo": repo,
                            "tag": tag,
                            "version": clean_ver,
                            "published_at": pub_at,
                            "asset_name": name,
                            "download_url": download_url
                        }
    return best_candidate

def prompt_confirm(msg, step_mode):
    if step_mode == "step_by_step":
        ans = input(f"\n{Colors.YELLOW}? {msg} Proceed? (y/N): {Colors.NC}").strip().lower()
        return ans in ["y", "yes"]
    return True

def install_pipeline(candidate, target_user, step_mode="auto"):
    os.makedirs(TEMP_DIR, exist_ok=True)
    rpm_path = os.path.join(TEMP_DIR, "thorium-latest.rpm")

    # Step 1: Download
    if not prompt_confirm(f"Download package '{candidate['asset_name']}' from {candidate['repo']}?", step_mode):
        log_warn("Download skipped by user.")
        return False

    log_info(f"Downloading: {candidate['download_url']}")
    try:
        req = urllib.request.Request(candidate["download_url"], headers={"User-Agent": "ThoriumManager"})
        with urllib.request.urlopen(req, timeout=60) as resp, open(rpm_path, "wb") as out_file:
            shutil.copyfileobj(resp, out_file)
    except Exception as e:
        log_err(f"Download failed: {e}")
        return False

    # Step 2: Verify Architecture
    res = subprocess.run(["rpm", "-qp", "--qf", "%{ARCH}", rpm_path], capture_output=True, text=True, check=False)
    arch = res.stdout.strip()
    if arch != "x86_64":
        log_err(f"Architecture mismatch! Expected x86_64, got '{arch}'. Aborting installation.")
        shutil.rmtree(TEMP_DIR, ignore_errors=True)
        return False
    log_ok("Package architecture verified: x86_64 AVX2.")

    # Step 3: Install RPM
    if not prompt_confirm("Install downloaded RPM package using DNF?", step_mode):
        log_warn("Installation skipped by user.")
        return False

    log_info("Installing with DNF...")
    install_res = subprocess.run(["dnf", "install", "-y", rpm_path], check=False)
    shutil.rmtree(TEMP_DIR, ignore_errors=True)

    if install_res.returncode != 0:
        log_err("DNF installation returned an error.")
        return False
    log_ok("Thorium package installed successfully.")

    # Step 4: Clean shortcuts and write custom desktop files
    if not prompt_confirm("Purge redundant shortcuts and configure Wayland launcher?", step_mode):
        log_warn("Shortcut configuration skipped.")
        return True

    clean_and_configure_shortcuts(target_user)
    return True

def clean_and_configure_shortcuts(target_user):
    user_home = f"/home/{target_user}"
    removals = [
        "/usr/share/applications/Thorium.desktop",
        "/usr/share/applications/org.chromium.Thorium.desktop",
        "/usr/share/applications/thorium-shell.desktop",
        os.path.join(user_home, ".local/share/applications/thorium-shell.desktop")
    ]
    for r in removals:
        if os.path.exists(r):
            try:
                os.remove(r)
            except Exception:
                pass

    desktop_path = os.path.join(user_home, ".local/share/applications/thorium.desktop")
    desktop_override = os.path.join(user_home, ".local/share/applications/thorium-browser.desktop")
    os.makedirs(os.path.dirname(desktop_path), exist_ok=True)

    for p in [desktop_path, desktop_override]:
        with open(p, "w", encoding="utf-8") as f:
            f.write(DESKTOP_ENTRY_CONTENT)
        try:
            user_info = pwd.getpwnam(target_user)
            os.chown(p, user_info.pw_uid, user_info.pw_gid)
            os.chmod(p, 0o644)
        except Exception:
            pass

    log_ok("Redundant desktop shortcuts purged.")
    log_ok("Custom Wayland desktop file generated.")

    subprocess.run(["update-desktop-database", "/usr/share/applications"], capture_output=True, check=False)
    subprocess.run(["su", "-", target_user, "-c", "update-desktop-database ~/.local/share/applications"],
                   capture_output=True, check=False)
    log_ok("Desktop database updated.")

def launch_gui_terminal():
    cfg = load_config()
    target_user = cfg.get("target_user", DEFAULT_USER)
    terminals = ["ptyxis", "gnome-terminal", "alacritty", "konsole", "xterm"]
    cmd = None
    for term in terminals:
        if shutil.which(term):
            if term == "ptyxis":
                cmd = f"su - {target_user} -c 'WAYLAND_DISPLAY=wayland-0 DISPLAY=:0 ptyxis -- /usr/local/bin/thorium-manager'"
            elif term == "gnome-terminal":
                cmd = f"su - {target_user} -c 'WAYLAND_DISPLAY=wayland-0 DISPLAY=:0 gnome-terminal -- /usr/local/bin/thorium-manager'"
            break
    if cmd:
        subprocess.Popen(cmd, shell=True)

def handle_scheduled_run():
    cfg = load_config()
    mode = cfg.get("mode", "interactive")
    installed_ver = get_installed_version()
    candidate = find_latest_avx2_rpm()

    if not candidate:
        sys.exit(0)

    if installed_ver and installed_ver == candidate["version"]:
        sys.exit(0)

    # An update is genuinely available!
    if mode == "unattended":
        install_pipeline(candidate, cfg.get("target_user", DEFAULT_USER), step_mode="auto")
    else:
        # Interactive mode: launch terminal window on user desktop
        launch_gui_terminal()
    sys.exit(0)

def show_tui():
    cfg = load_config()
    target_user = cfg.get("target_user", DEFAULT_USER)
    mode = cfg.get("mode", "interactive")

    os.system("clear")
    print(f"{Colors.CYAN}{Colors.BOLD}")
    print("  ╔══════════════════════════════════════════════════════════╗")
    print("  ║     THORIUM BROWSER AVX2 MANAGER & UPDATER (FOR RPM)     ║")
    print("  ╚══════════════════════════════════════════════════════════╝")
    print(f"{Colors.NC}")

    installed_ver = get_installed_version() or "Not Installed"
    print(f"  Target User   : {Colors.BOLD}{target_user}{Colors.NC}")
    print(f"  Current Mode  : {Colors.BOLD}{mode.upper()}{Colors.NC}")
    print(f"  Local Version : {Colors.YELLOW}{installed_ver}{Colors.NC}")
    print("  Checking online repositories (Alex313031 and gz83)...")

    candidate = find_latest_avx2_rpm()
    if candidate:
        print(f"  Online Latest : {Colors.GREEN}{candidate['version']}{Colors.NC} ({candidate['repo']})")
        update_available = (installed_ver != candidate["version"])
    else:
        print(f"  Online Latest : {Colors.RED}Unable to fetch release{Colors.NC}")
        update_available = False

    print("\n" + "─" * 60)
    if update_available:
        print(f"  {Colors.GREEN}{Colors.BOLD}► Status: Update Available!{Colors.NC}")
    else:
        print(f"  {Colors.CYAN}► Status: Thorium is up to date.{Colors.NC}")
    print("─" * 60 + "\n")

    print(f"  {Colors.GREEN}[1]{Colors.NC} {Colors.BOLD}Approve all steps for THIS session and run update{Colors.NC}")
    print(f"  {Colors.GREEN}[2]{Colors.NC} Step-by-step interactive approval")
    print(f"  {Colors.GREEN}[0]{Colors.NC} {Colors.BOLD}APPROVE ALL & SWITCH TO UNATTENDED MODE FOREVER{Colors.NC}")
    print(f"      (Never show this TUI again; daily check will update silently at 16:30)")
    if mode == "unattended":
        print(f"  {Colors.YELLOW}[3]{Colors.NC} Switch back to {Colors.BOLD}INTERACTIVE (TUI) MODE{Colors.NC}")
    print(f"  {Colors.CYAN}[4]{Colors.NC} Check systemd timer & service status")
    print(f"  {Colors.RED}[q]{Colors.NC} Quit\n")

    choice = input(f"{Colors.YELLOW}Enter your choice: {Colors.NC}").strip()

    if choice == "1":
        if candidate and update_available:
            install_pipeline(candidate, target_user, step_mode="auto")
        else:
            clean_and_configure_shortcuts(target_user)
            log_ok("Thorium is already latest. Launcher shortcuts refreshed.")
    elif choice == "2":
        if candidate:
            install_pipeline(candidate, target_user, step_mode="step_by_step")
        else:
            log_err("No remote candidate found to install.")
    elif choice == "0":
        cfg["mode"] = "unattended"
        save_config(cfg)
        log_ok("Switched to UNATTENDED mode forever. Daily updates will run silently.")
        if candidate and update_available:
            install_pipeline(candidate, target_user, step_mode="auto")
        else:
            clean_and_configure_shortcuts(target_user)
    elif choice == "3" and mode == "unattended":
        cfg["mode"] = "interactive"
        save_config(cfg)
        log_ok("Switched back to INTERACTIVE (TUI) mode.")
    elif choice == "4":
        print(f"\n{Colors.BOLD}=== Systemd Timer & Service Status ==={Colors.NC}")
        subprocess.run(["systemctl", "list-timers", "thorium-manager.timer", "--no-pager"], check=False)
        print("")
        subprocess.run(["systemctl", "status", "thorium-manager.timer", "--no-pager", "-l"], check=False)
    elif choice.lower() == "q":
        print("Exiting.")
        sys.exit(0)
    else:
        log_err("Invalid selection.")

def main():
    ensure_root()
    if len(sys.argv) > 1:
        arg = sys.argv[1]
        if arg == "--scheduled":
            handle_scheduled_run()
        elif arg == "--interactive":
            cfg = load_config()
            cfg["mode"] = "interactive"
            save_config(cfg)
            log_ok("Mode set to INTERACTIVE.")
            show_tui()
        elif arg == "--unattended":
            cfg = load_config()
            cfg["mode"] = "unattended"
            save_config(cfg)
            log_ok("Mode set to UNATTENDED.