package constants const ( // App names and IDs AppName = "mpv-manager" AppDisplayName = "MPV.Rocks Manager" AppNameMPV = "mpv" ConfigFileName = "mpv-manager.json" MPVConfigFileName = "mpv.conf" ModernZFontFile = "modernz-icons.ttf" UOSCIconsFontFile = "uosc_icons.otf" UOSCTexturesFontFile = "uosc_textures.ttf" // UI Type identifiers for MPV overlays UITypeUOSC = "uosc" UITypeModernZ = "modernz" UITypeNone = "none" // UITypeAmbiguous is discovery-only: both mutually exclusive overlay // scripts are present. It is never accepted as an installation choice. UITypeAmbiguous = "ambiguous" // Default UI for new installations DefaultUIType = UITypeModernZ // Config paths InstallDirName = "mpv" PortableConfigDir = "portable_config" ScriptsDir = "scripts" ScriptOptsDir = "script-opts" FontsDir = "fonts" ConfigBackupsDir = "conf_backups" MpvConfDir = ".config/mpv" // Windows installer directories InstallerDir = "mpv-manager" MPVInstallerDir = "" // zhongfly/mpv-winbuild has scripts at root level (not in subdirectory) MPVInstallBat = "mpv-register.bat" MPVUninstallBat = "mpv-unregister.bat" // Windows shortcut icons // NOTE: zhongfly/mpv-winbuild does not include .ico files. // Shortcuts use mpv.exe as the icon source (it has an embedded icon). // This constant is kept for backward compatibility with existing installations. InstallerIco = "mpv-manager.ico" ShortcutInstallName = "Set MPV as Default.lnk" ShortcutUninstallName = "Remove MPV from Defaults.lnk" ShortcutMPVName = "MPV.lnk" ShortcutInstallerName = "MPV Manager.lnk" UninstallBatFileName = "uninstall.bat" // Platform install method IDs MethodMPVBinary = "mpv-binary" MethodMPVBinaryV3 = "mpv-binary-v3" MethodMPCQT = "mpc-qt" MethodMPVApp = "mpv-app" MethodMPVBrew = "mpv-brew" MethodIINA = "iina" MethodMPVFlatpak = "mpv-flatpak" MethodCelluloidFlatpak = "celluloid-flatpak" MethodMPVPackage = "mpv-package" MethodCelluloidPackage = "celluloid-package" // Component method IDs (for UOSC, ModernZ, FFmpeg updates) MethodUOSC = "uosc" MethodModernZ = "modernz" MethodFFmpeg = "ffmpeg" // Flatpak App IDs FlatpakMPV = "io.mpv.Mpv" FlatpakCelluloid = "io.github.celluloid_player.Celluloid" // GSettings schema names (different from Flatpak app IDs!) // Note: Celluloid uses hyphen in schema but underscore in Flatpak app ID GSettingsCelluloidSchema = "io.github.celluloid-player.Celluloid" // Package names PackageMPV = "mpv" PackageCelluloid = "celluloid" // File permissions DirPermission = 0755 FilePermission = 0644 ExecutablePermission = 0755 // Command names CommandSudo = "sudo" CommandApt = "apt" CommandDnf = "dnf" CommandPacman = "pacman" CommandZypper = "zypper" CommandGsettings = "gsettings" // Timestamp format for backups BackupTimestampFormat = "2006-01-02" BackupTimestampFullFormat = "2006-01-02-150405" BackupTimestampUnique = "2006-01-02-150405.000000000" BackupFilePrefix = "-mpv.conf.bak" BackupDirFilePrefix = "_mpv.conf" // URLs FlathubRepoURL = "https://flathub.org/repo/flathub.flatpakrepo" RepositoryURL = "https://gitgud.io/mike/mpv-manager" // Command output settings OutputChanBufferSize = 100 // Placeholder values for development mode Blake3Placeholder = "blake3:HASH" // Error messages // Warning messages WarnFailedToInstallModernZ = "Warning: Failed to install ModernZ" WarnBackupFailed = "Warning: Failed to create backup" // Installation messages MsgConfigNotOverwritten = "Note: Configuration was not overwritten to preserve your settings" // Linux icon constants LinuxIconsDir = ".local/share/icons" LinuxIconThemeDir = "hicolor/128x128/apps" LinuxIconFileName = "mpv-manager.png" // macOS icon constants MacOSIconFileName = "icon.icns" MacOSTempIconDir = ".config/mpv/mpv-manager" // MPV config keys ConfigKeyAudioLanguage = "alang" ConfigKeySubtitleLanguage = "slang" ConfigKeyHardwareDecoder = "hwdec" ConfigKeyVideoOutput = "vo" ConfigKeyScaleFilter = "scale" ConfigKeyDitherAlgorithm = "dither-depth-convert" ConfigKeySavePositionOnQuit = "save-position-on-quit" ConfigKeyBorder = "border" ConfigKeyProfile = "profile" // MPV screenshot config keys ConfigKeyScreenshotFormat = "screenshot-format" ConfigKeyScreenshotTagColorspace = "screenshot-tag-colorspace" ConfigKeyScreenshotHighBitDepth = "screenshot-high-bit-depth" ConfigKeyScreenshotTemplate = "screenshot-template" ConfigKeyScreenshotDirectory = "screenshot-directory" ConfigKeyScreenshotJpegQuality = "screenshot-jpeg-quality" ConfigKeyScreenshotPngCompression = "screenshot-png-compression" ConfigKeyScreenshotWebpLossless = "screenshot-webp-lossless" ConfigKeyScreenshotWebpQuality = "screenshot-webp-quality" ConfigKeyScreenshotJxlDistance = "screenshot-jxl-distance" ConfigKeyScreenshotAvifEncoder = "screenshot-avif-encoder" ConfigKeyScreenshotAvifPixfmt = "screenshot-avif-pixfmt" ConfigKeyScreenshotAvifOpts = "screenshot-avif-opts" // HTTP content types ContentTypeJSON = "application/json" ContentTypeHTML = "text/html" // HTTP request limits. Browser requests use far fewer header values; this // keeps pathological requests below net/http's broader default of 500. HTTPMaxHeaderValueCount = 100 // Web UI pages and API routes shared across handlers and registration. RouteUISettings = "/ui-settings" RouteUIConfig = "/api/ui-config" RouteUIConfigSet = "/api/ui-config/set" RouteUIConfigReset = "/api/ui-config/reset" RouteUIConfigMigration = "/api/ui-config/migration" RouteModernZLegacy = "/modernz" RouteModernZConfig = "/api/modernz" RouteModernZConfigSet = "/api/modernz/set" RouteModernZConfigReset = "/api/modernz/reset" RouteHotkeyBindingSet = "/api/hotkeys/bindings/set" RouteHotkeyBindingRemove = "/api/hotkeys/bindings/remove" // Log message prefixes LogPrefixAPI = "[API]" // Modal types ModalTypeShutdown = "shutdown" ModalTypeUpdateManager = "update-manager" ModalTypeUpdateManagerSuccess = "update-manager-success" ModalTypeRemoveFileAssociations = "remove-file-associations" ModalTypeResetConfig = "reset-config" ModalTypeRestoreConfig = "restore-config" ModalTypeDeleteBackup = "delete-backup" ModalTypeClearLogs = "clear-logs" // Query parameter names QueryParamType = "type" QueryParamMethodID = "method_id" QueryParamAppName = "app_name" QueryParamAppType = "app_type" QueryParamInstallMethod = "install_method" QueryParamBackupPath = "backup_path" QueryParamVersion = "version" // Status values StatusShutdown = "shutdown" // Response messages ResponseMessageShutdown = "Server shutting down..." ResponseMessageMissingModalType = "Missing modal type" ResponseMessageUnknownModalType = "Unknown modal type" ResponseMessageMethodNotAllowed = "Method not allowed" ResponseMessageMissingAppName = "Missing app_name parameter" ResponseMessageMissingBackupPath = "Missing backup_path parameter" ResponseMessageInvalidBackupPath = "Invalid backup path" ) // MethodIDToName maps method IDs to display names var MethodIDToName = map[string]string{ MethodMPVBinary: "MPV", MethodMPVBinaryV3: "MPV (AVX2 optimized)", MethodMPCQT: "MPC-QT", MethodMPVApp: "MPV", MethodMPVBrew: "MPV (CLI only)", MethodIINA: "IINA", MethodMPVFlatpak: "MPV", MethodCelluloidFlatpak: "Celluloid", MethodMPVPackage: "MPV", MethodCelluloidPackage: "Celluloid", MethodUOSC: "uOSC", MethodModernZ: "ModernZ", MethodFFmpeg: "FFmpeg", } // MethodIDToAppID maps method IDs to their corresponding Flatpak/app IDs var MethodIDToAppID = map[string]string{ MethodMPVFlatpak: FlatpakMPV, MethodCelluloidFlatpak: FlatpakCelluloid, } // MethodIcon maps method IDs to Boxicon class names for Web UI var MethodIcon = map[string]string{ MethodMPVBinary: "bx bx-play-circle", MethodMPVBinaryV3: "bx bx-play-circle", MethodMPCQT: "bx bx-film", MethodMPVApp: "bx bx-play-circle", MethodMPVBrew: "bx bx-beer", MethodIINA: "bxl bxl-apple", MethodMPVFlatpak: "bx bx-box", MethodCelluloidFlatpak: "bx bx-box", MethodMPVPackage: "bx bx-play-circle", MethodCelluloidPackage: "bx bx-film", MethodUOSC: "bx bx-palette", MethodModernZ: "bx bx-palette", MethodFFmpeg: "bx bx-video", } // MethodLogo maps method IDs to logo image filenames for Web UI var MethodLogo = map[string]string{ MethodMPVBinary: "mpv.avif", MethodMPVBinaryV3: "mpv.avif", MethodMPCQT: "mpc.avif", MethodMPVApp: "mpv.avif", MethodMPVBrew: "mpv.avif", MethodIINA: "iina.avif", MethodMPVFlatpak: "mpv.avif", MethodMPVPackage: "mpv.avif", MethodCelluloidPackage: "celluloid.avif", MethodCelluloidFlatpak: "celluloid.avif", MethodUOSC: "uosc.avif", MethodModernZ: "modernz.avif", MethodFFmpeg: "ffmpeg.avif", } // MethodType maps method IDs to display type labels for Web UI var MethodType = map[string]string{ MethodMPVBinary: "Portable", MethodMPVBinaryV3: "Portable", MethodMPCQT: "Installed App", MethodMPVApp: "Portable", MethodMPVBrew: "Package Manager", MethodIINA: "Installed App", MethodMPVFlatpak: "Flatpak", MethodCelluloidFlatpak: "Flatpak", MethodMPVPackage: "Package Manager", MethodCelluloidPackage: "Package Manager", MethodUOSC: "UI Component", MethodModernZ: "UI Component", MethodFFmpeg: "Utility", } // MethodAppType maps method IDs to application type names for Web UI // Valid types: "app" (standalone apps), "frontend" (MPV frontends), or "component" (UI components/utilities) var MethodAppType = map[string]string{ MethodMPVBinary: "app", MethodMPVBinaryV3: "app", MethodMPCQT: "app", MethodMPVApp: "app", MethodMPVBrew: "app", MethodIINA: "app", MethodMPVFlatpak: "app", MethodCelluloidFlatpak: "frontend", MethodMPVPackage: "app", MethodCelluloidPackage: "frontend", MethodUOSC: "component", MethodModernZ: "component", MethodFFmpeg: "component", } // MethodHomepage maps method IDs to project homepage URLs for Web UI var MethodHomepage = map[string]string{ MethodMPVBinary: "https://mpv.io/", MethodMPVBinaryV3: "https://mpv.io/", MethodMPCQT: "https://github.com/mpc-qt/mpc-qt", MethodMPVApp: "https://mpv.io/", MethodMPVBrew: "https://brew.sh/", MethodIINA: "https://iina.io/", MethodMPVFlatpak: "https://flathub.org/apps/details/io.mpv.Mpv", MethodCelluloidFlatpak: "https://flathub.org/apps/details/io.github.celluloid_player.Celluloid", MethodMPVPackage: "https://mpv.io/", MethodCelluloidPackage: "https://celluloid-player.github.io/", MethodUOSC: "https://github.com/tomasklaen/uosc", MethodModernZ: "https://github.com/Samillion/ModernZ", MethodFFmpeg: "https://ffmpeg.org/", } // Architecture identifiers const ( // ArchI686 is kept for error messaging; not used in build selection logic. ArchI686 = "i686" ArchX8664 = "x86-64" ArchX8664V3 = "x86-64-v3" ArchAarch64 = "aarch64" Arch386 = "386" ArchAMD64 = "amd64" ArchARM64 = "arm64" ) // OS identifiers const ( OSWindows = "windows" OSLinux = "linux" ) // Package manager families const ( PMFamilyDebian = "debian" PMFamilyRHEL = "rhel" PMFamilyArch = "arch" PMFamilySUSE = "suse" ) // Package not found error patterns for detection var PackageNotFoundPatterns = []string{ "package not found", "unable to locate package", "no match for argument", "target not found", "not installed", "no such keg", "no such formula", } // Package manager commands structure type PackageManagerCommands struct { Install []string Update []string Upgrade []string Remove []string Makecache []string Refresh []string } // PackageManagerConfigs contains command configurations for each package manager var PackageManagerConfigs = map[string]PackageManagerCommands{ CommandApt: { Install: []string{"apt", "install", "-y"}, Update: []string{"apt", "update"}, Upgrade: []string{"apt", "upgrade", "-y"}, Remove: []string{"apt", "remove", "-y"}, Makecache: []string{"apt", "update"}, }, CommandDnf: { Install: []string{"dnf", "install", "-y"}, Update: []string{"dnf", "makecache"}, Upgrade: []string{"dnf", "upgrade", "-y"}, Remove: []string{"dnf", "remove", "-y"}, Makecache: []string{"dnf", "makecache"}, }, CommandPacman: { // Install/Upgrade use -Syu: refresh databases and perform a full system // upgrade in one transaction. `pacman -Sy ` is the partial-upgrade // pattern Arch explicitly warns against. Install: []string{"pacman", "-Syu", "--noconfirm"}, Update: []string{"pacman", "-Sy"}, Upgrade: []string{"pacman", "-Syu", "--noconfirm"}, Remove: []string{"pacman", "-Rns", "--noconfirm"}, Makecache: []string{"pacman", "-Sy"}, }, CommandZypper: { Install: []string{"zypper", "--non-interactive", "install"}, Update: []string{"zypper", "refresh"}, Upgrade: []string{"zypper", "--non-interactive", "update"}, Remove: []string{"zypper", "--non-interactive", "remove"}, Makecache: []string{"zypper", "refresh"}, Refresh: []string{"zypper", "refresh"}, }, } // Coordination paths must survive config replacement and installer mutations. const ( ConfigCoordinationName = ".mpv-manager-config-coordination" InstallerLockFileName = ".mpv-manager-installer.lock" // MPCQTSetupFileName was historically downloaded into the MPV install root. MPCQTSetupFileName = "mpc-qt-setup.exe" ) // WindowsPreservePaths are reserved top-level entries, never owned by a payload. // fileops.AcquireAdvisory adds a leading dot and .lock to its coordination name. var WindowsPreservePaths = []string{ PortableConfigDir, InstallerDir, "." + ConfigCoordinationName + ".lock", InstallerLockFileName, MPCQTSetupFileName, } var WindowsRemoveDirs = []string{"cache", "temp", "shaders", "scripts", "script-opts", "fonts"}