"""Complete registry of applications and their configuration paths.

Each entry maps an application to its binary, icon, category, dotfiles
and optional skel paths. This is the single source of truth for what
the app can reset.
"""

from __future__ import annotations

from dataclasses import dataclass, field


@dataclass(frozen=True, slots=True)
class AppEntry:
    """Describes one application whose config can be restored."""

    app_id: str
    name: str
    icon: str  # icon-name (themed) or absolute path
    binary: str  # path to executable — used to detect installation
    category: str  # must match a CATEGORIES key
    config_paths: list[str]  # paths relative to $HOME (~ prefix)
    skel_paths: list[str] = field(default_factory=list)  # /etc/skel/ sources
    process_name: str = ""  # for pgrep; defaults to binary basename
    is_de: bool = False  # desktop-environment full reset
    logout_required: bool = False  # needs session restart after reset


# ---------------------------------------------------------------------------
# Categories — id, translatable label, icon-name
# ---------------------------------------------------------------------------
CATEGORIES: list[dict[str, str]] = [
    {"id": "favorites", "label": "Favorites", "icon": "view-app-grid-symbolic"},
    {"id": "browsers", "label": "Browsers", "icon": "web-browser-symbolic"},
    {"id": "communication", "label": "Communication", "icon": "mail-send-symbolic"},
    {"id": "multimedia", "label": "Multimedia", "icon": "applications-multimedia-symbolic"},
    {"id": "graphics", "label": "Graphics", "icon": "applications-graphics-symbolic"},
    {"id": "office", "label": "Office", "icon": "x-office-document-symbolic"},
    {"id": "development", "label": "Development", "icon": "project-development"},
    {"id": "terminals", "label": "Terminals", "icon": "utilities-terminal-symbolic"},
    {"id": "shell", "label": "Shell", "icon": "format-text-code"},
    {"id": "filemanagers", "label": "File Managers", "icon": "system-file-manager-symbolic"},
    {"id": "downloads", "label": "Downloads", "icon": "folder-download-symbolic"},
    {"id": "system", "label": "System", "icon": "emblem-system-symbolic"},
    {"id": "gaming", "label": "Gaming", "icon": "applications-games-symbolic"},
    {"id": "customization", "label": "Customization", "icon": "kdenlive-custom-effect"},
    {"id": "desktop_env", "label": "Desktop Environment", "icon": "user-desktop-symbolic"},
]

# Lookup helper
CATEGORY_IDS: set[str] = {c["id"] for c in CATEGORIES}

# ---------------------------------------------------------------------------
# Favorites — apps that always show in favorites if installed (no MIME-based detection)
# ---------------------------------------------------------------------------
STATIC_FAVORITE_IDS: set[str] = {
    "gimp", "libreoffice", "lutris", "steam",
    "dolphin", "spectacle", "konsole",
}

# MIME types used to detect the system default app for each favorite "slot"
# Each tuple: (mime_type_or_command, description)
# The xdg-settings command is used for web browser; xdg-mime for the rest.
FAVORITE_MIME_SLOTS: list[tuple[str, str]] = [
    ("x-scheme-handler/http", "browser"),
    ("application/pdf", "pdf_viewer"),
    ("image/png", "image_viewer"),
    ("text/plain", "text_editor"),
    ("video/mp4", "media_player"),
]

# ---------------------------------------------------------------------------
# Full application registry
# ---------------------------------------------------------------------------
APP_REGISTRY: list[AppEntry] = [
    # ── Browsers ──────────────────────────────────────────────────────────
    AppEntry(
        app_id="firefox",
        name="Firefox",
        icon="firefox",
        binary="/usr/lib/firefox/firefox",
        category="browsers",
        config_paths=["~/.mozilla"],
        skel_paths=["/etc/skel/.mozilla"],
    ),
    AppEntry(
        app_id="brave",
        name="Brave",
        icon="brave-browser",
        binary="/usr/lib/brave-browser/brave",
        category="browsers",
        config_paths=["~/.config/BraveSoftware"],
    ),
    AppEntry(
        app_id="google-chrome",
        name="Google Chrome",
        icon="google-chrome",
        binary="/opt/google/chrome/google-chrome",
        category="browsers",
        config_paths=["~/.config/google-chrome"],
    ),
    AppEntry(
        app_id="chromium",
        name="Chromium",
        icon="chromium",
        binary="/usr/lib/chromium/chromium",
        category="browsers",
        config_paths=["~/.config/chromium"],
        skel_paths=["/etc/skel/.config/chromium"],
    ),
    AppEntry(
        app_id="vivaldi",
        name="Vivaldi",
        icon="vivaldi",
        binary="/usr/bin/vivaldi",
        category="browsers",
        config_paths=["~/.config/vivaldi"],
    ),
    AppEntry(
        app_id="microsoft-edge",
        name="Microsoft Edge",
        icon="microsoft-edge",
        binary="/usr/bin/microsoft-edge-stable",
        category="browsers",
        config_paths=["~/.config/microsoft-edge"],
    ),
    AppEntry(
        app_id="opera",
        name="Opera",
        icon="opera",
        binary="/usr/bin/opera",
        category="browsers",
        config_paths=["~/.config/opera"],
    ),
    AppEntry(
        app_id="palemoon",
        name="Pale Moon",
        icon="palemoon",
        binary="/usr/lib/palemoon/palemoon",
        category="browsers",
        config_paths=["~/.moonchild productions"],
    ),
    AppEntry(
        app_id="tor-browser",
        name="Tor Browser",
        icon="torbrowser",
        binary="/usr/bin/torbrowser-launcher",
        category="browsers",
        config_paths=["~/.local/share/torbrowser"],
    ),
    AppEntry(
        app_id="midori",
        name="Midori",
        icon="midori",
        binary="/usr/bin/midori",
        category="browsers",
        config_paths=["~/.config/midori"],
    ),
    AppEntry(
        app_id="epiphany",
        name="GNOME Web",
        icon="org.gnome.Epiphany",
        binary="/usr/bin/epiphany",
        category="browsers",
        config_paths=["~/.local/share/epiphany", "~/.config/epiphany"],
    ),
    AppEntry(
        app_id="floorp",
        name="Floorp",
        icon="floorp",
        binary="/usr/lib/floorp/floorp",
        category="browsers",
        config_paths=["~/.floorp"],
    ),
    AppEntry(
        app_id="zen-browser",
        name="Zen Browser",
        icon="zen-browser",
        binary="/usr/bin/zen-browser",
        category="browsers",
        config_paths=["~/.zen"],
    ),
    AppEntry(
        app_id="librewolf",
        name="LibreWolf",
        icon="librewolf",
        binary="/usr/bin/librewolf",
        category="browsers",
        config_paths=["~/.librewolf"],
    ),

    # ── Communication ─────────────────────────────────────────────────────
    AppEntry(
        app_id="thunderbird",
        name="Thunderbird",
        icon="thunderbird",
        binary="/usr/bin/thunderbird",
        category="communication",
        config_paths=["~/.thunderbird"],
    ),
    AppEntry(
        app_id="telegram-desktop",
        name="Telegram Desktop",
        icon="telegram",
        binary="/usr/bin/telegram-desktop",
        category="communication",
        config_paths=["~/.local/share/TelegramDesktop"],
    ),
    AppEntry(
        app_id="discord",
        name="Discord",
        icon="discord",
        binary="/usr/bin/discord",
        category="communication",
        config_paths=["~/.config/discord"],
    ),
    AppEntry(
        app_id="signal-desktop",
        name="Signal",
        icon="signal-desktop",
        binary="/usr/bin/signal-desktop",
        category="communication",
        config_paths=["~/.config/Signal"],
    ),
    AppEntry(
        app_id="element-desktop",
        name="Element",
        icon="io.element.Element",
        binary="/usr/bin/element-desktop",
        category="communication",
        config_paths=["~/.config/Element"],
    ),
    AppEntry(
        app_id="slack",
        name="Slack",
        icon="slack",
        binary="/usr/bin/slack",
        category="communication",
        config_paths=["~/.config/Slack"],
    ),
    AppEntry(
        app_id="hexchat",
        name="HexChat",
        icon="hexchat",
        binary="/usr/bin/hexchat",
        category="communication",
        config_paths=["~/.config/hexchat"],
    ),
    AppEntry(
        app_id="evolution",
        name="Evolution",
        icon="evolution",
        binary="/usr/bin/evolution",
        category="communication",
        config_paths=["~/.config/evolution", "~/.local/share/evolution"],
    ),
    AppEntry(
        app_id="geary",
        name="Geary",
        icon="org.gnome.Geary",
        binary="/usr/bin/geary",
        category="communication",
        config_paths=["~/.local/share/geary"],
    ),

    # ── Multimedia — Video ────────────────────────────────────────────────
    AppEntry(
        app_id="vlc",
        name="VLC",
        icon="vlc",
        binary="/usr/bin/vlc",
        category="multimedia",
        config_paths=["~/.config/vlc"],
        skel_paths=["/etc/skel/.config/vlc"],
    ),
    AppEntry(
        app_id="smplayer",
        name="SMPlayer",
        icon="smplayer",
        binary="/usr/bin/smplayer",
        category="multimedia",
        config_paths=["~/.config/smplayer"],
        skel_paths=["/etc/skel/.config/smplayer"],
    ),
    AppEntry(
        app_id="mpv",
        name="mpv",
        icon="mpv",
        binary="/usr/bin/mpv",
        category="multimedia",
        config_paths=["~/.config/mpv"],
        skel_paths=["/etc/skel/.config/mpv"],
    ),
    AppEntry(
        app_id="celluloid",
        name="Celluloid",
        icon="io.github.celluloid_player.Celluloid",
        binary="/usr/bin/celluloid",
        category="multimedia",
        config_paths=["~/.config/celluloid"],
    ),
    AppEntry(
        app_id="totem",
        name="GNOME Videos",
        icon="org.gnome.Totem",
        binary="/usr/bin/totem",
        category="multimedia",
        config_paths=["~/.config/totem", "~/.local/share/totem"],
    ),
    AppEntry(
        app_id="parole",
        name="Parole",
        icon="org.xfce.parole",
        binary="/usr/bin/parole",
        category="multimedia",
        config_paths=["~/.config/parole"],
    ),
    AppEntry(
        app_id="haruna",
        name="Haruna",
        icon="org.kde.haruna",
        binary="/usr/bin/haruna",
        category="multimedia",
        config_paths=["~/.config/haruna"],
    ),
    AppEntry(
        app_id="kodi",
        name="Kodi",
        icon="kodi",
        binary="/usr/bin/kodi",
        category="multimedia",
        config_paths=["~/.kodi"],
    ),
    AppEntry(
        app_id="obs-studio",
        name="OBS Studio",
        icon="com.obsproject.Studio",
        binary="/usr/bin/obs",
        category="multimedia",
        config_paths=["~/.config/obs-studio", "~/.config/obs-portable"],
    ),
    AppEntry(
        app_id="kdenlive",
        name="Kdenlive",
        icon="kdenlive",
        binary="/usr/bin/kdenlive",
        category="multimedia",
        config_paths=["~/.config/kdenlive", "~/.local/share/kdenlive"],
    ),
    AppEntry(
        app_id="shotcut",
        name="Shotcut",
        icon="org.shotcut.Shotcut",
        binary="/usr/bin/shotcut",
        category="multimedia",
        config_paths=["~/.config/Meltytech"],
    ),
    AppEntry(
        app_id="handbrake",
        name="HandBrake",
        icon="fr.handbrake.ghb",
        binary="/usr/bin/ghb",
        category="multimedia",
        config_paths=["~/.config/ghb"],
    ),
    AppEntry(
        app_id="mystiq",
        name="MystiQ",
        icon="mystiq",
        binary="/usr/bin/mystiq",
        category="multimedia",
        config_paths=["~/.config/mystiq"],
        skel_paths=["/etc/skel/.config/mystiq"],
    ),
    AppEntry(
        app_id="vokoscreenng",
        name="vokoscreenNG",
        icon="vokoscreenNG",
        binary="/usr/bin/vokoscreenNG",
        category="multimedia",
        config_paths=["~/.config/vokoscreenNG"],
    ),

    # ── Multimedia — Audio ────────────────────────────────────────────────
    AppEntry(
        app_id="clementine",
        name="Clementine",
        icon="clementine",
        binary="/usr/bin/clementine",
        category="multimedia",
        config_paths=["~/.config/Clementine"],
        skel_paths=["/etc/skel/.config/Clementine"],
    ),
    AppEntry(
        app_id="rhythmbox",
        name="Rhythmbox",
        icon="rhythmbox",
        binary="/usr/bin/rhythmbox",
        category="multimedia",
        config_paths=["~/.local/share/rhythmbox", "~/.config/rhythmbox"],
    ),
    AppEntry(
        app_id="strawberry",
        name="Strawberry",
        icon="strawberry",
        binary="/usr/bin/strawberry",
        category="multimedia",
        config_paths=["~/.config/strawberry"],
        skel_paths=["/etc/skel/.config/strawberry"],
    ),
    AppEntry(
        app_id="audacious",
        name="Audacious",
        icon="audacious",
        binary="/usr/bin/audacious",
        category="multimedia",
        config_paths=["~/.config/audacious"],
    ),
    AppEntry(
        app_id="lollypop",
        name="Lollypop",
        icon="org.gnome.Lollypop",
        binary="/usr/bin/lollypop",
        category="multimedia",
        config_paths=["~/.local/share/lollypop"],
    ),
    AppEntry(
        app_id="elisa",
        name="Elisa",
        icon="org.kde.elisa",
        binary="/usr/bin/elisa",
        category="multimedia",
        config_paths=["~/.config/elisa"],
    ),
    AppEntry(
        app_id="audacity",
        name="Audacity",
        icon="audacity",
        binary="/usr/bin/audacity",
        category="multimedia",
        config_paths=["~/.config/audacity", "~/.audacity-data"],
    ),
    AppEntry(
        app_id="lmms",
        name="LMMS",
        icon="lmms",
        binary="/usr/bin/lmms",
        category="multimedia",
        config_paths=["~/.config/lmms", "~/.lmms"],
    ),
    AppEntry(
        app_id="spotify",
        name="Spotify",
        icon="spotify-client",
        binary="/usr/bin/spotify",
        category="multimedia",
        config_paths=["~/.config/spotify"],
    ),

    # ── Graphics ──────────────────────────────────────────────────────────
    AppEntry(
        app_id="gimp",
        name="GIMP",
        icon="gimp",
        binary="/usr/bin/gimp",
        category="graphics",
        config_paths=["~/.config/GIMP"],
        skel_paths=["/etc/skel/.config/GIMP"],
    ),
    AppEntry(
        app_id="inkscape",
        name="Inkscape",
        icon="inkscape",
        binary="/usr/bin/inkscape",
        category="graphics",
        config_paths=["~/.config/inkscape"],
    ),
    AppEntry(
        app_id="krita",
        name="Krita",
        icon="krita",
        binary="/usr/bin/krita",
        category="graphics",
        config_paths=["~/.config/kritarc", "~/.config/kritadisplayrc", "~/.local/share/krita"],
    ),
    AppEntry(
        app_id="gwenview",
        name="Gwenview",
        icon="gwenview",
        binary="/usr/bin/gwenview",
        category="graphics",
        config_paths=[
            "~/.local/share/gwenview",
            "~/.local/share/kxmlgui5/gwenview",
            "~/.config/gwenviewrc"
        ],
        skel_paths=[
            "/etc/skel/.config/gwenviewrc",
            "/etc/skel/.local/share/kxmlgui5/gwenview"
        ],
    ),
    AppEntry(
        app_id="ristretto",
        name="Ristretto",
        icon="org.xfce.ristretto",
        binary="/usr/bin/ristretto",
        category="graphics",
        config_paths=["~/.config/ristretto"],
    ),
    AppEntry(
        app_id="eog",
        name="Eye of GNOME",
        icon="eog",
        binary="/usr/bin/eog",
        category="graphics",
        config_paths=["~/.config/eog"],
    ),
    AppEntry(
        app_id="loupe",
        name="Loupe",
        icon="org.gnome.Loupe",
        binary="/usr/bin/loupe",
        category="graphics",
        config_paths=["~/.config/loupe"],
    ),
    AppEntry(
        app_id="shotwell",
        name="Shotwell",
        icon="shotwell",
        binary="/usr/bin/shotwell",
        category="graphics",
        config_paths=["~/.local/share/shotwell"],
    ),
    AppEntry(
        app_id="digikam",
        name="digiKam",
        icon="digikam",
        binary="/usr/bin/digikam",
        category="graphics",
        config_paths=["~/.config/digikamrc", "~/.local/share/digikam"],
    ),
    AppEntry(
        app_id="blender",
        name="Blender",
        icon="blender",
        binary="/usr/bin/blender",
        category="graphics",
        config_paths=["~/.config/blender"],
    ),
    AppEntry(
        app_id="darktable",
        name="darktable",
        icon="darktable",
        binary="/usr/bin/darktable",
        category="graphics",
        config_paths=["~/.config/darktable"],
    ),
    AppEntry(
        app_id="ksnip",
        name="Ksnip",
        icon="ksnip",
        binary="/usr/bin/ksnip",
        category="graphics",
        config_paths=["~/.config/ksnip"],
        skel_paths=["/etc/skel/.config/ksnip"],
    ),
    AppEntry(
        app_id="flameshot",
        name="Flameshot",
        icon="flameshot",
        binary="/usr/bin/flameshot",
        category="graphics",
        config_paths=["~/.config/flameshot"],
    ),
    AppEntry(
        app_id="spectacle",
        name="Spectacle",
        icon="spectacle",
        binary="/usr/bin/spectacle",
        category="graphics",
        config_paths=["~/.config/spectaclerc"],
        skel_paths=["/etc/skel/.config/spectaclerc"],
    ),

    # ── Office ────────────────────────────────────────────────────────────
    AppEntry(
        app_id="libreoffice",
        name="LibreOffice",
        icon="libreoffice-startcenter",
        binary="/usr/bin/libreoffice",
        category="office",
        config_paths=["~/.config/libreoffice"],
        skel_paths=["/etc/skel/.config/libreoffice"],
    ),
    AppEntry(
        app_id="okular",
        name="Okular",
        icon="okular",
        binary="/usr/bin/okular",
        category="office",
        config_paths=[
            "~/.local/share/okular",
            "~/.local/share/kxmlgui5/okular",
            "~/.config/okularrc",
            "~/.config/okularpartrc"
        ],
        skel_paths=[
            "/etc/skel/.config/okularrc",
            "/etc/skel/.config/okularpartrc",
            "/etc/skel/.local/share/okular",
            "/etc/skel/.local/share/kxmlgui5/okular"
        ],
    ),
    AppEntry(
        app_id="evince",
        name="Evince",
        icon="org.gnome.Evince",
        binary="/usr/bin/evince",
        category="office",
        config_paths=["~/.config/evince"],
    ),
    AppEntry(
        app_id="calibre",
        name="Calibre",
        icon="calibre-gui",
        binary="/usr/bin/calibre",
        category="office",
        config_paths=["~/.config/calibre"],
    ),
    AppEntry(
        app_id="xournalpp",
        name="Xournal++",
        icon="com.github.xournalpp.xournalpp",
        binary="/usr/bin/xournalpp",
        category="office",
        config_paths=["~/.config/xournalpp"],
    ),
    AppEntry(
        app_id="zathura",
        name="Zathura",
        icon="org.pwmt.zathura",
        binary="/usr/bin/zathura",
        category="office",
        config_paths=["~/.config/zathura"],
    ),
    AppEntry(
        app_id="onlyoffice",
        name="OnlyOffice",
        icon="onlyoffice-desktopeditors",
        binary="/usr/bin/onlyoffice-desktopeditors",
        category="office",
        config_paths=["~/.config/onlyoffice"],
    ),
    AppEntry(
        app_id="obsidian",
        name="Obsidian",
        icon="obsidian",
        binary="/usr/bin/obsidian",
        category="office",
        config_paths=["~/.config/obsidian"],
    ),
    AppEntry(
        app_id="logseq",
        name="Logseq",
        icon="logseq",
        binary="/usr/bin/logseq",
        category="office",
        config_paths=["~/.config/Logseq", "~/.logseq"],
    ),

    # ── Development ───────────────────────────────────────────────────────
    AppEntry(
        app_id="kate",
        name="Kate",
        icon="kate",
        binary="/usr/bin/kate",
        category="development",
        config_paths=[
            "~/.local/share/kate",
            "~/.local/share/kxmlgui5/kate",
            "~/.local/share/kxmlgui5/katepart",
            "~/.local/share/ktexteditor_snippets",
            "~/.config/katerc",
            "~/.config/kateschemarc",
            "~/.config/katemetainfos",
            "~/.config/katevirc",
            "~/.config/katesyntaxhighlightingrc",
        ],
        skel_paths=[
            "/etc/skel/.config/katerc",
            "/etc/skel/.config/kateschemarc",
            "/etc/skel/.local/share/kate",
            "/etc/skel/.local/share/kxmlgui5/kate",
            "/etc/skel/.local/share/kxmlgui5/katepart",
        ],
    ),
    AppEntry(
        app_id="vscode",
        name="Visual Studio Code",
        icon="visual-studio-code",
        binary="/usr/bin/code",
        category="development",
        config_paths=["~/.config/Code", "~/.vscode"],
    ),
    AppEntry(
        app_id="vscode-insiders",
        name="VS Code Insiders",
        icon="visual-studio-code-insiders",
        binary="/usr/bin/code-insiders",
        category="development",
        config_paths=["~/.config/Code - Insiders", "~/.vscode-insiders"],
    ),
    AppEntry(
        app_id="sublime-text",
        name="Sublime Text",
        icon="sublime-text",
        binary="/usr/bin/subl",
        category="development",
        config_paths=["~/.config/sublime-text"],
    ),
    AppEntry(
        app_id="gedit",
        name="gedit",
        icon="org.gnome.gedit",
        binary="/usr/bin/gedit",
        category="development",
        config_paths=["~/.config/gedit", "~/.local/share/gedit"],
    ),
    AppEntry(
        app_id="gnome-text-editor",
        name="GNOME Text Editor",
        icon="org.gnome.TextEditor",
        binary="/usr/bin/gnome-text-editor",
        category="development",
        config_paths=["~/.config/gnome-text-editor"],
    ),
    AppEntry(
        app_id="mousepad",
        name="Mousepad",
        icon="org.xfce.mousepad",
        binary="/usr/bin/mousepad",
        category="development",
        config_paths=["~/.config/Mousepad"],
    ),
    AppEntry(
        app_id="neovim",
        name="Neovim",
        icon="nvim",
        binary="/usr/bin/nvim",
        category="development",
        config_paths=["~/.config/nvim", "~/.local/share/nvim", "~/.local/state/nvim"],
    ),
    AppEntry(
        app_id="vim",
        name="Vim",
        icon="gvim",
        binary="/usr/bin/vim",
        category="development",
        config_paths=["~/.vimrc", "~/.vim"],
    ),
    AppEntry(
        app_id="emacs",
        name="Emacs",
        icon="emacs",
        binary="/usr/bin/emacs",
        category="development",
        config_paths=["~/.emacs", "~/.emacs.d"],
    ),
    AppEntry(
        app_id="geany",
        name="Geany",
        icon="geany",
        binary="/usr/bin/geany",
        category="development",
        config_paths=["~/.config/geany"],
    ),

    # ── Terminals ─────────────────────────────────────────────────────────
    AppEntry(
        app_id="konsole",
        name="Konsole",
        icon="konsole",
        binary="/usr/bin/konsole",
        category="terminals",
        config_paths=[
            "~/.config/konsolerc",
            "~/.local/share/konsole",
            "~/.local/share/kxmlgui5/konsole"
        ],
        skel_paths=[
            "/etc/skel/.config/konsolerc",
            "/etc/skel/.local/share/konsole",
            "/etc/skel/.local/share/kxmlgui5/konsole"
        ],
    ),
    AppEntry(
        app_id="gnome-terminal",
        name="GNOME Terminal",
        icon="org.gnome.Terminal",
        binary="/usr/bin/gnome-terminal",
        category="terminals",
        config_paths=["~/.config/gnome-terminal"],
    ),
    AppEntry(
        app_id="xfce4-terminal",
        name="XFCE4 Terminal",
        icon="org.xfce.terminalemulator",
        binary="/usr/bin/xfce4-terminal",
        category="terminals",
        config_paths=["~/.config/xfce4/terminal"],
        skel_paths=["/etc/skel/.config/xfce4/terminal"],
    ),
    AppEntry(
        app_id="alacritty",
        name="Alacritty",
        icon="Alacritty",
        binary="/usr/bin/alacritty",
        category="terminals",
        config_paths=["~/.config/alacritty"],
    ),
    AppEntry(
        app_id="kitty",
        name="Kitty",
        icon="kitty",
        binary="/usr/bin/kitty",
        category="terminals",
        config_paths=["~/.config/kitty"],
    ),
    AppEntry(
        app_id="wezterm",
        name="WezTerm",
        icon="org.wezfurlong.wezterm",
        binary="/usr/bin/wezterm",
        category="terminals",
        config_paths=["~/.config/wezterm"],
    ),
    AppEntry(
        app_id="tilix",
        name="Tilix",
        icon="com.gexperts.Tilix",
        binary="/usr/bin/tilix",
        category="terminals",
        config_paths=["~/.config/tilix"],
    ),
    AppEntry(
        app_id="yakuake",
        name="Yakuake",
        icon="yakuake",
        binary="/usr/bin/yakuake",
        category="terminals",
        config_paths=["~/.config/yakuakerc"],
    ),
    AppEntry(
        app_id="terminator",
        name="Terminator",
        icon="terminator",
        binary="/usr/bin/terminator",
        category="terminals",
        config_paths=["~/.config/terminator"],
    ),
    AppEntry(
        app_id="foot",
        name="foot",
        icon="foot",
        binary="/usr/bin/foot",
        category="terminals",
        config_paths=["~/.config/foot"],
    ),
    AppEntry(
        app_id="guake",
        name="Guake",
        icon="guake",
        binary="/usr/bin/guake",
        category="terminals",
        config_paths=["~/.config/guake"],
    ),

    # ── Shell ─────────────────────────────────────────────────────────────
    AppEntry(
        app_id="bash",
        name="Bash",
        icon="bash",
        binary="/usr/bin/bash",
        category="shell",
        config_paths=["~/.bashrc", "~/.bash_profile", "~/.bash_history", "~/.bash_logout"],
        skel_paths=["/etc/skel/.bashrc", "/etc/skel/.bash_profile"],
    ),
    AppEntry(
        app_id="zsh",
        name="Zsh",
        icon="zsh",
        binary="/usr/bin/zsh",
        category="shell",
        config_paths=["~/.zshrc", "~/.zsh_history", "~/.zshenv", "~/.zprofile"],
        skel_paths=["/etc/skel/.zshrc"],
    ),
    AppEntry(
        app_id="fish",
        name="Fish",
        icon="fish",
        binary="/usr/bin/fish",
        category="shell",
        config_paths=["~/.config/fish"],
    ),
    AppEntry(
        app_id="starship",
        name="Starship",
        icon="starship",
        binary="/usr/bin/starship",
        category="shell",
        config_paths=["~/.config/starship.toml"],
    ),

    # ── File Managers ─────────────────────────────────────────────────────
    AppEntry(
        app_id="dolphin",
        name="Dolphin",
        icon="system-file-manager",
        binary="/usr/bin/dolphin",
        category="filemanagers",
        config_paths=[
            "~/.local/share/dolphin",
            "~/.local/share/kxmlgui5/dolphin",
            "~/.config/dolphinrc",
        ],
        skel_paths=[
            "/etc/skel/.config/dolphinrc",
            "/etc/skel/.local/share/dolphin",
            "/etc/skel/.local/share/kxmlgui5/dolphin"
        ],
    ),
    AppEntry(
        app_id="nautilus",
        name="Nautilus",
        icon="org.gnome.Nautilus",
        binary="/usr/bin/nautilus",
        category="filemanagers",
        config_paths=["~/.config/nautilus", "~/.local/share/nautilus"],
    ),
    AppEntry(
        app_id="nemo",
        name="Nemo",
        icon="nemo",
        binary="/usr/bin/nemo",
        category="filemanagers",
        config_paths=["~/.config/nemo", "~/.local/share/nemo"],
    ),
    AppEntry(
        app_id="thunar",
        name="Thunar",
        icon="org.xfce.thunar",
        binary="/usr/bin/thunar",
        category="filemanagers",
        config_paths=["~/.config/Thunar", "~/.config/thunar"],
    ),
    AppEntry(
        app_id="pcmanfm",
        name="PCManFM",
        icon="system-file-manager",
        binary="/usr/bin/pcmanfm",
        category="filemanagers",
        config_paths=["~/.config/pcmanfm"],
    ),
    AppEntry(
        app_id="caja",
        name="Caja",
        icon="caja",
        binary="/usr/bin/caja",
        category="filemanagers",
        config_paths=["~/.config/caja"],
    ),
    AppEntry(
        app_id="doublecmd",
        name="Double Commander",
        icon="doublecmd",
        binary="/usr/bin/doublecmd",
        category="filemanagers",
        config_paths=["~/.config/doublecmd"],
    ),
    AppEntry(
        app_id="krusader",
        name="Krusader",
        icon="krusader_user",
        binary="/usr/bin/krusader",
        category="filemanagers",
        config_paths=["~/.config/krusaderrc", "~/.local/share/krusader"],
    ),

    # ── Downloads / Torrent ───────────────────────────────────────────────
    AppEntry(
        app_id="qbittorrent",
        name="qBittorrent",
        icon="qbittorrent",
        binary="/usr/bin/qbittorrent",
        category="downloads",
        config_paths=["~/.config/qBittorrent", "~/.local/share/qBittorrent"],
        skel_paths=["/etc/skel/.config/qBittorrent"],
    ),
    AppEntry(
        app_id="transmission",
        name="Transmission",
        icon="transmission",
        binary="/usr/bin/transmission-gtk",
        category="downloads",
        config_paths=["~/.config/transmission"],
    ),
    AppEntry(
        app_id="deluge",
        name="Deluge",
        icon="deluge",
        binary="/usr/bin/deluge",
        category="downloads",
        config_paths=["~/.config/deluge"],
    ),
    AppEntry(
        app_id="ktorrent",
        name="KTorrent",
        icon="ktorrent",
        binary="/usr/bin/ktorrent",
        category="downloads",
        config_paths=["~/.config/ktorrentrc", "~/.local/share/ktorrent"],
    ),

    # ── System & Utilities ────────────────────────────────────────────────
    AppEntry(
        app_id="bleachbit",
        name="BleachBit",
        icon="bleachbit",
        binary="/usr/bin/bleachbit",
        category="system",
        config_paths=["~/.config/bleachbit"],
    ),
    AppEntry(
        app_id="stacer",
        name="Stacer",
        icon="stacer",
        binary="/usr/bin/stacer",
        category="system",
        config_paths=["~/.config/stacer"],
    ),
    AppEntry(
        app_id="virtualbox",
        name="VirtualBox",
        icon="virtualbox",
        binary="/usr/bin/VirtualBox",
        category="system",
        config_paths=["~/.config/VirtualBox"],
    ),
    AppEntry(
        app_id="gnome-boxes",
        name="GNOME Boxes",
        icon="org.gnome.Boxes",
        binary="/usr/bin/gnome-boxes",
        category="system",
        config_paths=["~/.config/gnome-boxes", "~/.local/share/gnome-boxes"],
    ),
    AppEntry(
        app_id="virt-manager",
        name="Virt Manager",
        icon="virt-manager",
        binary="/usr/bin/virt-manager",
        category="system",
        config_paths=["~/.config/virt-manager"],
    ),
    AppEntry(
        app_id="keepassxc",
        name="KeePassXC",
        icon="keepassxc",
        binary="/usr/bin/keepassxc",
        category="system",
        config_paths=["~/.config/keepassxc"],
    ),
    AppEntry(
        app_id="bitwarden",
        name="Bitwarden",
        icon="bitwarden",
        binary="/usr/bin/bitwarden",
        category="system",
        config_paths=["~/.config/Bitwarden"],
    ),
    AppEntry(
        app_id="syncthing",
        name="Syncthing",
        icon="syncthing",
        binary="/usr/bin/syncthing",
        category="system",
        config_paths=["~/.config/syncthing"],
    ),
    AppEntry(
        app_id="rclone",
        name="Rclone",
        icon="rclone",
        binary="/usr/bin/rclone",
        category="system",
        config_paths=["~/.config/rclone"],
    ),
    AppEntry(
        app_id="htop",
        name="htop",
        icon="htop",
        binary="/usr/bin/htop",
        category="system",
        config_paths=["~/.config/htop"],
        skel_paths=["/etc/skel/.config/htop"],
    ),
    AppEntry(
        app_id="btop",
        name="btop",
        icon="btop",
        binary="/usr/bin/btop",
        category="system",
        config_paths=["~/.config/btop"],
    ),

    # ── Gaming ────────────────────────────────────────────────────────────
    AppEntry(
        app_id="steam",
        name="Steam",
        icon="steam",
        binary="/usr/bin/steam",
        category="gaming",
        config_paths=["~/.steam", "~/.local/share/Steam"],
    ),
    AppEntry(
        app_id="lutris",
        name="Lutris",
        icon="lutris",
        binary="/usr/bin/lutris",
        category="gaming",
        config_paths=["~/.config/lutris", "~/.local/share/lutris"],
    ),
    AppEntry(
        app_id="heroic",
        name="Heroic Games Launcher",
        icon="com.heroicgameslauncher.hgl",
        binary="/usr/bin/heroic",
        category="gaming",
        config_paths=["~/.config/heroic"],
    ),
    AppEntry(
        app_id="bottles",
        name="Bottles",
        icon="com.usebottles.bottles",
        binary="/usr/bin/bottles",
        category="gaming",
        config_paths=["~/.local/share/bottles"],
    ),
    AppEntry(
        app_id="mangohud",
        name="MangoHud",
        icon="mangohud",
        binary="/usr/bin/mangohud",
        category="gaming",
        config_paths=["~/.config/MangoHud"],
    ),
    AppEntry(
        app_id="gamemode",
        name="GameMode",
        icon="gamemode",
        binary="/usr/bin/gamemoded",
        category="gaming",
        config_paths=["~/.config/gamemode.ini"],
    ),

    # ── Customization ────────────────────────────────────────────────────
    AppEntry(
        app_id="gnome-tweaks",
        name="GNOME Tweaks",
        icon="org.gnome.tweaks",
        binary="/usr/bin/gnome-tweaks",
        category="customization",
        config_paths=[],  # modifies dconf only
    ),
    AppEntry(
        app_id="kvantum",
        name="Kvantum Manager",
        icon="kvantum",
        binary="/usr/bin/kvantummanager",
        category="customization",
        config_paths=["~/.config/Kvantum"],
    ),
    AppEntry(
        app_id="conky",
        name="Conky",
        icon="conky",
        binary="/usr/bin/conky",
        category="customization",
        config_paths=["~/.config/conky", "~/.conkyrc"],
    ),
    AppEntry(
        app_id="plank",
        name="Plank",
        icon="plank",
        binary="/usr/bin/plank",
        category="customization",
        config_paths=["~/.config/plank"],
    ),
    AppEntry(
        app_id="lxappearance",
        name="LXAppearance",
        icon="preferences-desktop-theme",
        binary="/usr/bin/lxappearance",
        category="customization",
        config_paths=["~/.config/gtk-3.0/settings.ini", "~/.gtkrc-2.0"],
    ),

    # ── Desktop Environments (full reset) ─────────────────────────────────
    AppEntry(
        app_id="de-kde",
        name="KDE Plasma",
        icon="preferences-desktop-plasma",
        binary="/usr/bin/plasmashell",
        category="desktop_env",
        config_paths=[
            "~/.config/plasma-org.kde.plasma.desktop-appletsrc",
            "~/.config/plasmarc",
            "~/.config/plasmashellrc",
            "~/.config/kwinrc",
            "~/.config/kwinrulesrc",
            "~/.config/kdeglobals",
            "~/.config/kglobalshortcutsrc",
            "~/.config/khotkeysrc",
            "~/.config/kcminputrc",
            "~/.config/kscreenlockerrc",
            "~/.config/ksmserverrc",
            "~/.config/ksplashrc",
            "~/.config/ktimezonedrc",
            "~/.config/kactivitymanagerd-statsrc",
            "~/.config/kactivitymanagerdrc",
            "~/.config/baloofilerc",
            "~/.config/dolphinrc",
            "~/.config/konsolerc",
            "~/.config/systemsettingsrc",
            "~/.local/share/plasma",
            "~/.local/share/kwin",
            "~/.local/share/kxmlgui5",
            "~/.local/share/konsole",
            "~/.local/share/dolphin",
        ],
        skel_paths=["/etc/skel/.config", "/etc/skel/.local"],
        is_de=True,
        logout_required=True,
        process_name="plasmashell",
    ),
    AppEntry(
        app_id="de-xfce",
        name="XFCE",
        icon="xfce4-logo",
        binary="/usr/bin/xfce4-session",
        category="desktop_env",
        config_paths=[
            "~/.config/xfce4",
            "~/.config/Thunar",
            "~/.config/gtk-3.0",
        ],
        skel_paths=["/etc/skel/.config/xfce4"],
        is_de=True,
        logout_required=True,
        process_name="xfce4-session",
    ),
    AppEntry(
        app_id="de-gnome",
        name="GNOME",
        icon="desktop-environment-gnome",
        binary="/usr/bin/gnome-shell",
        category="desktop_env",
        config_paths=[
            "~/.config/gnome-session",
            "~/.config/gnome-shell",
            "~/.local/share/gnome-shell",
        ],
        skel_paths=["/etc/skel/.config/dconf"],
        is_de=True,
        logout_required=True,
        process_name="gnome-shell",
    ),
    AppEntry(
        app_id="de-cinnamon",
        name="Cinnamon",
        icon="cinnamon-symbolic",
        binary="/usr/bin/cinnamon",
        category="desktop_env",
        config_paths=[
            "~/.config/cinnamon",
            "~/.cinnamon",
            "~/.local/share/cinnamon",
        ],
        is_de=True,
        logout_required=True,
        process_name="cinnamon",
    ),
    AppEntry(
        app_id="de-dde",
        name="Deepin (DDE)",
        icon="deepin-toggle-desktop",
        binary="/usr/bin/dde-session",
        category="desktop_env",
        config_paths=[
            "~/.config/deepin",
            "~/.local/share/deepin",
        ],
        is_de=True,
        logout_required=True,
        process_name="dde-session",
    ),
    AppEntry(
        app_id="de-mate",
        name="MATE",
        icon="mate-desktop",
        binary="/usr/bin/mate-session",
        category="desktop_env",
        config_paths=[
            "~/.config/mate",
            "~/.local/share/mate",
        ],
        is_de=True,
        logout_required=True,
        process_name="mate-session",
    ),
    AppEntry(
        app_id="de-budgie",
        name="Budgie",
        icon="budgie-desktop-symbolic",
        binary="/usr/bin/budgie-desktop",
        category="desktop_env",
        config_paths=[
            "~/.config/budgie-desktop",
            "~/.config/budgie-extras",
        ],
        is_de=True,
        logout_required=True,
        process_name="budgie-desktop",
    ),
]

# Build a lookup dict for fast access by app_id
APP_REGISTRY_MAP: dict[str, AppEntry] = {entry.app_id: entry for entry in APP_REGISTRY}
