22namespace fs = std::filesystem;
36using PipePtr = std::unique_ptr<FILE, PipeDeleter>;
67 const char* homeEnv = std::getenv(
"HOME");
68 std::vector<std::string> searchPaths = {
"/usr/bin/umu-run",
"/usr/local/bin/umu-run",
69 std::string(homeEnv ? homeEnv :
"") +
70 "/.local/bin/umu-run"};
72 for (
const auto& path : searchPaths)
85 std::array<char, 256> buffer;
86 PipePtr pipe(popen(
"which umu-run 2>/dev/null",
"r"));
89 if (fgets(buffer.data(), buffer.size(), pipe.get()) !=
nullptr)
91 std::string result = buffer.data();
93 if (!result.empty() && result.back() ==
'\n')
95 if (!result.empty() && fs::exists(result))
107 std::array<char, 256> buffer;
109 PipePtr pipe(popen(cmd.c_str(),
"r"));
112 if (fgets(buffer.data(), buffer.size(), pipe.get()) !=
nullptr)
122 const char* home = std::getenv(
"HOME");
133 const char* home = std::getenv(
"HOME");
138 std::vector<std::string> searchDirs = {
139 std::string(home) +
"/.local/share/Steam/compatibilitytools.d",
140 std::string(home) +
"/.steam/steam/compatibilitytools.d",
141 std::string(home) +
"/.steam/root/compatibilitytools.d"};
143 for (
const auto& dir : searchDirs)
145 if (!fs::exists(dir))
150 for (
const auto& entry : fs::directory_iterator(dir))
152 if (!entry.is_directory())
155 std::string name = entry.path().filename().string();
158 std::string protonFile = entry.path().string() +
"/proton";
159 if (!fs::exists(protonFile))
164 version.
path = entry.path().string();
167 if (name.find(
"GE-Proton") != std::string::npos)
172 else if (name.find(
"UMU-Proton") != std::string::npos)
177 else if (name.find(
"Proton") != std::string::npos)
183 std::regex versionRegex(R
"((\d+[\.\-]\d+(?:[\.\-]\d+)?))");
185 if (std::regex_search(name, match, versionRegex))
187 version.
version = match[1].str();
193 catch (
const std::exception& e)
195 Logger::warn(
"Error scanning Proton directory {}: {}", dir, e.what());
204 if (a.isGEProton != b.isGEProton)
206 if (a.isUMUProton != b.isUMUProton)
207 return a.isUMUProton;
208 return a.version > b.version;
216 const char* home = std::getenv(
"HOME");
233 std::vector<std::string> dbPaths;
238 dbPaths.push_back(
"/usr/share/umu/umu-database.csv");
239 dbPaths.push_back(
"/usr/local/share/umu/umu-database.csv");
240 dbPaths.push_back(std::string(home) +
"/.local/share/umu/umu-database.csv");
243 for (
const auto& path : dbPaths)
245 if (fs::exists(path))
254 Logger::debug(
"UMU database not found in standard locations");
259 std::ifstream file(dbPath);
262 Logger::warn(
"Failed to open UMU database: {}", dbPath);
267 bool isHeader =
true;
268 size_t gameIdCol = SIZE_MAX, titleCol = SIZE_MAX, storeCol = SIZE_MAX;
269 size_t codenameCol = SIZE_MAX, notesCol = SIZE_MAX;
271 while (std::getline(file, line))
273 if (line.empty() || line[0] ==
'#')
277 std::vector<std::string> fields;
279 bool inQuotes =
false;
285 inQuotes = !inQuotes;
287 else if (c ==
',' && !inQuotes)
289 fields.push_back(field);
297 fields.push_back(field);
302 for (
size_t i = 0; i < fields.size(); ++i)
304 std::string col = fields[i];
306 std::transform(col.begin(), col.end(), col.begin(),
307 [](
unsigned char c) { return static_cast<char>(::tolower(c)); });
309 if (col ==
"gameid" || col ==
"game_id")
311 else if (col ==
"title" || col ==
"name")
313 else if (col ==
"store")
315 else if (col ==
"codename")
317 else if (col ==
"notes")
321 if (gameIdCol == SIZE_MAX)
323 Logger::warn(
"[UMU] Database CSV has no recognizable game ID column"
324 " — database will be empty");
331 if (gameIdCol < fields.size())
332 entry.
gameId = fields[gameIdCol];
333 if (titleCol < fields.size())
334 entry.
title = fields[titleCol];
335 if (storeCol < fields.size())
336 entry.
store = fields[storeCol];
337 if (codenameCol < fields.size())
338 entry.
codename = fields[codenameCol];
339 if (notesCol < fields.size())
340 entry.
notes = fields[notesCol];
342 if (!entry.
gameId.empty())
359 if (entry.gameId == gameId)
362 info.
title = entry.title;
363 info.
store = entry.store;
365 if (!entry.notes.empty())
367 info.
fixes.push_back(entry.notes);
377 std::optional<UMUStore> storeFilter)
const
379 std::vector<UMUGameInfo> results;
381 std::string lowerQuery = query;
382 std::transform(lowerQuery.begin(), lowerQuery.end(), lowerQuery.begin(),
383 [](
unsigned char c) { return static_cast<char>(::tolower(c)); });
385 std::string storeFilterStr;
386 if (storeFilter.has_value())
394 if (!storeFilterStr.empty())
396 std::string entryStore = entry.store;
397 std::transform(entryStore.begin(), entryStore.end(), entryStore.begin(),
398 [](
unsigned char c) { return static_cast<char>(::tolower(c)); });
399 if (entryStore != storeFilterStr)
406 std::string lowerTitle = entry.title;
407 std::string lowerGameId = entry.gameId;
408 std::string lowerCodename = entry.codename;
409 std::transform(lowerTitle.begin(), lowerTitle.end(), lowerTitle.begin(),
410 [](
unsigned char c) { return static_cast<char>(::tolower(c)); });
411 std::transform(lowerGameId.begin(), lowerGameId.end(), lowerGameId.begin(),
412 [](
unsigned char c) { return static_cast<char>(::tolower(c)); });
413 std::transform(lowerCodename.begin(), lowerCodename.end(), lowerCodename.begin(),
414 [](
unsigned char c) { return static_cast<char>(::tolower(c)); });
416 if (lowerTitle.find(lowerQuery) != std::string::npos ||
417 lowerGameId.find(lowerQuery) != std::string::npos ||
418 lowerCodename.find(lowerQuery) != std::string::npos)
421 info.
gameId = entry.gameId;
422 info.
title = entry.title;
423 info.
store = entry.store;
425 if (!entry.notes.empty())
427 info.
fixes.push_back(entry.notes);
429 results.push_back(info);
432 if (results.size() >= 50)
462 return impl_->isAvailable_;
470 status.
version = impl_->version_;
480 return impl_->umuRunPath_;
485 impl_->refreshProtonVersions();
490 return impl_->protonVersions_;
495 if (!impl_->isAvailable_)
501 std::ostringstream cmd;
513 cmd <<
"PROTONPATH=GE-Proton ";
523 for (
const auto& p : impl_->protonVersions_)
525 if (p.isSystemProton)
539 if (!config.
gameId.empty())
547 std::string storeStr =
549 if (!storeStr.empty())
558 cmd <<
"UMU_LOG=debug ";
562 cmd <<
"PROTON_LOG=1 ";
584 Logger::warn(
"[UMU] Skipping invalid env var name: {}", key);
604 std::map<std::string, std::string>& envVars,
605 std::vector<std::string>& command)
const
610 if (!impl_->isAvailable_)
623 envVars[
"PROTONPATH"] =
"GE-Proton";
632 for (
const auto& p : impl_->protonVersions_)
634 if (p.isSystemProton)
636 envVars[
"PROTONPATH"] = p.path;
646 if (!config.
gameId.empty())
648 envVars[
"GAMEID"] = config.
gameId;
654 std::string storeStr =
656 if (!storeStr.empty())
658 envVars[
"STORE"] = storeStr;
665 envVars[
"UMU_LOG"] =
"debug";
669 envVars[
"PROTON_LOG"] =
"1";
682 envVars[key] = value;
684 Logger::warn(
"[UMU] Skipping invalid env var name: {}", key);
688 command.push_back(impl_->umuRunPath_);
692 command.push_back(arg);
699 UMUGameInfo info = impl_->lookupGameInDatabase(gameId);
702 if (!info.
found && gameId.rfind(
"umu-", 0) == 0)
705 info.
title = gameId.substr(4);
714 std::optional<UMUStore> store)
const
716 return impl_->searchDatabase(query, store);
723 std::string gameId =
"umu-";
725 for (
char c : gameName)
727 if (std::isalnum(
static_cast<unsigned char>(c)))
729 gameId +=
static_cast<char>(std::tolower(
static_cast<unsigned char>(c)));
731 else if (c ==
' ' || c ==
'_' || c ==
'-')
733 if (!gameId.empty() && gameId.back() !=
'-')
741 while (!gameId.empty() && gameId.back() ==
'-')
751 if (!impl_->isAvailable_)
753 Logger::error(
"UMU is not available for GE-Proton download");
759 if (progressCallback)
761 progressCallback(0,
"Initiating GE-Proton download via UMU...");
766 int result = std::system(cmd.c_str());
767 bool success = (result != -1 && WIFEXITED(result) && WEXITSTATUS(result) == 0);
769 if (progressCallback)
771 progressCallback(100, success ?
"GE-Proton ready" :
"Download may have failed");
775 impl_->refreshProtonVersions();
777 return impl_->hasGEProton_;
782 if (!impl_->isAvailable_)
784 Logger::error(
"UMU is not available for UMU-Proton download");
790 if (progressCallback)
792 progressCallback(0,
"Initiating UMU-Proton download...");
796 int result = std::system(cmd.c_str());
797 bool success = (result != -1 && WIFEXITED(result) && WEXITSTATUS(result) == 0);
799 if (progressCallback)
801 progressCallback(100, success ?
"UMU-Proton ready" :
"Download may have failed");
804 impl_->refreshProtonVersions();
806 return impl_->hasUMUProton_;
812 if (impl_->protonVersions_.empty())
827 constexpr int kCurrentGEProtonMajor = 10;
828 constexpr int kFutureGEProtonMajorWarn = kCurrentGEProtonMajor + 2;
830 for (
const auto& version : impl_->protonVersions_)
832 if (version.isGEProton)
835 std::regex versionRegex(R
"(GE-Proton(\d+)-(\d+))");
837 if (std::regex_search(version.name, match, versionRegex))
842 major = std::stoi(match[1].str());
844 catch (
const std::exception&)
849 if (major < kCurrentGEProtonMajor)
853 if (major >= kFutureGEProtonMajorWarn)
858 Logger::warn(
"[UMU] Installed GE-Proton major {} is newer than the audited "
859 "current ({}); update kCurrentGEProtonMajor in umu_launcher.cpp.",
860 major, kCurrentGEProtonMajor);
874 const char* home = std::getenv(
"HOME");
878 std::string
id = gameId.empty() ?
"umu-default" : gameId;
879 return std::string(home) +
"/Games/umu/" + id;
884 return fs::exists(prefixPath) && fs::is_directory(prefixPath);
889 if (!impl_->isAvailable_)
896 std::ostringstream cmd;
899 if (!protonPath.empty())
907 int result = std::system(cmd.str().c_str());
909 return result != -1 && WIFEXITED(result) && WEXITSTATUS(result) == 0 && fs::exists(prefixPath);
913 const std::vector<std::string>& verbs,
914 const std::string& protonPath,
917 if (!impl_->isAvailable_ || verbs.empty())
923 std::ostringstream verbList;
924 for (
size_t i = 0; i < verbs.size(); ++i)
931 std::ostringstream cmd;
934 if (!protonPath.empty())
940 cmd <<
"PROTONPATH=GE-Proton ";
945 if (progressCallback)
947 progressCallback(0,
"Running winetricks: " + verbList.str());
950 Logger::info(
"Running winetricks in {}: {}", prefixPath, verbList.str());
951 int result = std::system(cmd.str().c_str());
952 bool success = (result != -1 && WIFEXITED(result) && WEXITSTATUS(result) == 0);
954 if (progressCallback)
956 progressCallback(100, success ?
"Winetricks completed" :
"Winetricks failed");
991 std::string lower = str;
992 std::transform(lower.begin(), lower.end(), lower.begin(),
993 [](
unsigned char c) { return static_cast<char>(::tolower(c)); });
995 if (lower ==
"steam")
997 if (lower ==
"egs" || lower ==
"epic")
1001 if (lower ==
"amazon")
1003 if (lower ==
"ubisoft" || lower ==
"uplay")
1005 if (lower ==
"ea" || lower ==
"origin")
1007 if (lower ==
"humble")
1009 if (lower ==
"itch" || lower ==
"itchio")
1022 return "Epic Games Store";
1026 return "Amazon Games";
1028 return "Ubisoft Connect";
1032 return "Humble Bundle";
static void info(const std::string &message, Args &&... args)
Log info message (general information).
static void debug(const std::string &message, Args &&... args)
Log debug message (verbose development info).
static void error(const std::string &message, Args &&... args)
Log error message (recoverable failure).
static void warn(const std::string &message, Args &&... args)
Log warning message (non-critical issue).
static std::string escapeArg(const std::string &arg)
Escape a string for safe use as a shell argument.
static bool isValidEnvName(const std::string &name)
Validate an environment variable name.
void refreshProtonVersions()
UMUGameInfo lookupGameInDatabase(const std::string &gameId) const
std::vector< UMUGameInfo > searchDatabase(const std::string &query, std::optional< UMUStore > storeFilter) const
std::vector< UMUDatabaseEntry > database_
std::vector< UMUProtonVersion > protonVersions_
bool hasProtonUpdates() const
Check if Proton updates are available.
std::vector< UMUProtonVersion > getAvailableProtonVersions() const
Get available Proton versions for UMU.
bool downloadUMUProton(const ProgressCallback &progressCallback=nullptr)
Download latest UMU-Proton.
bool createPrefix(const std::string &prefixPath, const std::string &protonPath="")
Create a new Wine prefix via umu-run.
void refreshProtonVersions()
Refresh the list of available Proton versions.
bool runWinetricks(const std::string &prefixPath, const std::vector< std::string > &verbs, const std::string &protonPath="", const ProgressCallback &progressCallback=nullptr)
Run winetricks verbs in a prefix via umu.
std::string suggestGameId(const std::string &gameName, UMUStore store=UMUStore::None) const
Get suggested GAMEID for a game name.
UMUGameInfo lookupGame(const std::string &gameId) const
Look up a game in the umu database.
bool isAvailable() const
Check if umu-run is available on the system.
bool prefixExists(const std::string &prefixPath) const
Check if a Wine prefix exists.
static UMUStore storeFromString(const std::string &str)
Parse store identifier from string.
std::string buildLaunchCommand(const UMULaunchConfig &config) const
Build the full launch command for umu-run.
bool downloadGEProton(const ProgressCallback &progressCallback=nullptr)
Download latest GE-Proton for UMU.
static std::string storeToString(UMUStore store)
Get store identifier string from enum.
std::vector< UMUGameInfo > searchGames(const std::string &query, std::optional< UMUStore > store=std::nullopt) const
Search for games in the umu database.
std::function< void(int percent, const std::string &status)> ProgressCallback
std::string getDefaultPrefixPath(const std::string &gameId) const
Get the default Wine prefix path for a GAMEID.
std::string getUMURunPath() const
Get path to umu-run binary.
UMUInstallStatus getInstallStatus() const
Get detailed installation status.
void buildLaunchComponents(const UMULaunchConfig &config, std::map< std::string, std::string > &envVars, std::vector< std::string > &command) const
Build launch command as separate components.
void operator()(FILE *pipe) const noexcept
Information about a game from the umu database.
std::string store
Store identifier.
bool found
Whether game was found in database.
std::string gameId
umu game ID (e.g., "umu-dauntless")
std::string title
Game title.
std::vector< std::string > fixes
List of fixes applied.
Status of UMU installation on the system.
std::string umuRunPath
Path to umu-run binary.
std::string runtimePath
Path to Steam Runtime (~/.local/share/umu).
bool hasGEProton
Is GE-Proton available.
bool hasUMUProton
Is UMU-Proton available.
std::string version
UMU version string.
std::vector< UMUProtonVersion > availableProton
Available Proton versions.
bool isInstalled
Is umu-run available.
Configuration for launching a game via umu-run.
UMUStore store
Storefront for store-specific fixes.
UMUProtonPath protonPathMode
std::string winePrefix
WINEPREFIX path (empty = default at $HOME/Games/umu/GAMEID).
bool enableProtonLog
Enable Proton verbose logging.
std::string protonVerb
PROTON_VERB (e.g., "runinprefix" for multi-game prefix).
std::map< std::string, std::string > environmentVariables
std::string gameId
GAMEID for umu database lookup (e.g., "umu-dauntless").
std::vector< std::string > arguments
Arguments to pass to the executable.
std::string customProtonPath
Custom Proton path when mode is Custom.
std::string customStore
Custom store name when store is Custom.
std::string executable
Path to game executable.
bool enableUMULog
Enable UMU debug logging.
Information about an available Proton version.
bool isUMUProton
Is official UMU-Proton build.
bool isGEProton
Is GloriousEggroll build.
bool isSystemProton
Is system/Steam Proton.
std::string version
Parsed version number.
std::string name
Version name (e.g., "GE-Proton9-20").
std::string path
Full path to the Proton directory.
std::string umuStoreName(UMUStore store)
Get human-readable store name.
std::unique_ptr< FILE, PipeDeleter > PipePtr
UMUStore
Storefront identifiers for game fixes lookup.
@ Ubisoft
Ubisoft Connect.
@ Steam
Steam (usually use Steam directly, but for reference).
@ None
No specific store (generic fixes only).
@ Custom
Custom store identifier.
@ GEProton
Auto-download latest GE-Proton.
@ Default
Use UMU-Proton (stable Valve Proton with umu patches).
@ Custom
Use custom PROTONPATH specified in customProtonPath.
@ SystemProton
Use system-installed Proton.