game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
umu_launcher.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// ==============================================================================
3// umu_launcher.cpp
4// ==============================================================================
5// UMU (Unified Linux Wine Game Launcher) integration implementation
6// ==============================================================================
7
8#include "umu_launcher.h"
9#include "logger.h"
10#include "shell_utils.h"
11
12#include <algorithm>
13#include <array>
14#include <cstdlib>
15#include <filesystem>
16#include <fstream>
17#include <memory>
18#include <regex>
19#include <sstream>
20#include <sys/wait.h>
21
22namespace fs = std::filesystem;
23
24// ==============================================================================
25// Helper for popen/pclose RAII
26// ==============================================================================
27
29{
30 void operator()(FILE* pipe) const noexcept
31 {
32 if (pipe)
33 pclose(pipe);
34 }
35};
36using PipePtr = std::unique_ptr<FILE, PipeDeleter>;
37
38// ==============================================================================
39// Implementation
40// ==============================================================================
41
42// ==============================================================================
43// UMU Database Entry (parsed from umu-database.csv)
44// ==============================================================================
46{
47 std::string gameId; // GAMEID column
48 std::string title; // TITLE column
49 std::string store; // STORE column (egs, gog, etc.)
50 std::string codename; // CODENAME column (internal name)
51 std::string notes; // NOTES column
52};
53
55{
56 public:
63
65 {
66 // Check common locations for umu-run
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"};
71
72 for (const auto& path : searchPaths)
73 {
74 if (fs::exists(path))
75 {
76 umuRunPath_ = path;
77 isAvailable_ = true;
78 break;
79 }
80 }
81
82 // Fallback: check PATH via which
83 if (!isAvailable_)
84 {
85 std::array<char, 256> buffer;
86 PipePtr pipe(popen("which umu-run 2>/dev/null", "r"));
87 if (pipe)
88 {
89 if (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr)
90 {
91 std::string result = buffer.data();
92 // Remove trailing newline
93 if (!result.empty() && result.back() == '\n')
94 result.pop_back();
95 if (!result.empty() && fs::exists(result))
96 {
97 umuRunPath_ = result;
98 isAvailable_ = true;
99 }
100 }
101 }
102 }
103
104 // Get version if available
105 if (isAvailable_)
106 {
107 std::array<char, 256> buffer;
108 std::string cmd = ShellUtils::escapeArg(umuRunPath_) + " --version 2>&1";
109 PipePtr pipe(popen(cmd.c_str(), "r"));
110 if (pipe)
111 {
112 if (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr)
113 {
114 version_ = buffer.data();
115 if (!version_.empty() && version_.back() == '\n')
116 version_.pop_back();
117 }
118 }
119 }
120
121 // Check runtime path
122 const char* home = std::getenv("HOME");
123 if (home)
124 {
125 runtimePath_ = std::string(home) + "/.local/share/umu";
126 }
127 }
128
130 {
131 protonVersions_.clear();
132
133 const char* home = std::getenv("HOME");
134 if (!home)
135 return;
136
137 // Search directories for Proton versions
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"};
142
143 for (const auto& dir : searchDirs)
144 {
145 if (!fs::exists(dir))
146 continue;
147
148 try
149 {
150 for (const auto& entry : fs::directory_iterator(dir))
151 {
152 if (!entry.is_directory())
153 continue;
154
155 std::string name = entry.path().filename().string();
156
157 // Check if it's a Proton directory
158 std::string protonFile = entry.path().string() + "/proton";
159 if (!fs::exists(protonFile))
160 continue;
161
162 UMUProtonVersion version;
163 version.name = name;
164 version.path = entry.path().string();
165
166 // Categorize
167 if (name.find("GE-Proton") != std::string::npos)
168 {
169 version.isGEProton = true;
170 hasGEProton_ = true;
171 }
172 else if (name.find("UMU-Proton") != std::string::npos)
173 {
174 version.isUMUProton = true;
175 hasUMUProton_ = true;
176 }
177 else if (name.find("Proton") != std::string::npos)
178 {
179 version.isSystemProton = true;
180 }
181
182 // Parse version number
183 std::regex versionRegex(R"((\d+[\.\-]\d+(?:[\.\-]\d+)?))");
184 std::smatch match;
185 if (std::regex_search(name, match, versionRegex))
186 {
187 version.version = match[1].str();
188 }
189
190 protonVersions_.push_back(version);
191 }
192 }
193 catch (const std::exception& e)
194 {
195 Logger::warn("Error scanning Proton directory {}: {}", dir, e.what());
196 }
197 }
198
199 // Sort by version (newest first)
200 std::sort(protonVersions_.begin(), protonVersions_.end(),
201 [](const UMUProtonVersion& a, const UMUProtonVersion& b)
202 {
203 // GE-Proton first, then UMU-Proton, then others
204 if (a.isGEProton != b.isGEProton)
205 return a.isGEProton;
206 if (a.isUMUProton != b.isUMUProton)
207 return a.isUMUProton;
208 return a.version > b.version;
209 });
210 }
211
213 {
214 database_.clear();
215
216 const char* home = std::getenv("HOME");
217 if (!home)
218 return;
219
220 // Search for umu-database.csv in common locations.
221 //
222 // Order is significant. The canonical sources are (in priority):
223 // 1. The umu-launcher install dir (`runtimePath_`), which is what the
224 // AUR/multilib package and the upstream installer drop the CSV
225 // next to umu-run itself.
226 // 2. System-wide /usr[/local]/share/umu paths used by distro
227 // packages that split data from the bin.
228 // 3. `~/.local/share/umu/umu-database.csv` is a *fallback* — older
229 // umu builds wrote it there and some users still have a copy,
230 // but it is no longer the canonical location and may go stale.
231 //
232 // Upstream canonical CSV: https://github.com/Open-Wine-Components/umu-database
233 std::vector<std::string> dbPaths;
234 if (!runtimePath_.empty())
235 {
236 dbPaths.push_back(runtimePath_ + "/umu-database.csv");
237 }
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");
241
242 std::string dbPath;
243 for (const auto& path : dbPaths)
244 {
245 if (fs::exists(path))
246 {
247 dbPath = path;
248 break;
249 }
250 }
251
252 if (dbPath.empty())
253 {
254 Logger::debug("UMU database not found in standard locations");
255 return;
256 }
257
258 // Parse CSV database
259 std::ifstream file(dbPath);
260 if (!file.is_open())
261 {
262 Logger::warn("Failed to open UMU database: {}", dbPath);
263 return;
264 }
265
266 std::string line;
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;
270
271 while (std::getline(file, line))
272 {
273 if (line.empty() || line[0] == '#')
274 continue;
275
276 // Parse CSV line (handle quoted fields)
277 std::vector<std::string> fields;
278 std::string field;
279 bool inQuotes = false;
280
281 for (char c : line)
282 {
283 if (c == '"')
284 {
285 inQuotes = !inQuotes;
286 }
287 else if (c == ',' && !inQuotes)
288 {
289 fields.push_back(field);
290 field.clear();
291 }
292 else
293 {
294 field += c;
295 }
296 }
297 fields.push_back(field);
298
299 if (isHeader)
300 {
301 // Parse header to find column indices
302 for (size_t i = 0; i < fields.size(); ++i)
303 {
304 std::string col = fields[i];
305 // Normalize column name
306 std::transform(col.begin(), col.end(), col.begin(),
307 [](unsigned char c) { return static_cast<char>(::tolower(c)); });
308
309 if (col == "gameid" || col == "game_id")
310 gameIdCol = i;
311 else if (col == "title" || col == "name")
312 titleCol = i;
313 else if (col == "store")
314 storeCol = i;
315 else if (col == "codename")
316 codenameCol = i;
317 else if (col == "notes")
318 notesCol = i;
319 }
320 isHeader = false;
321 if (gameIdCol == SIZE_MAX)
322 {
323 Logger::warn("[UMU] Database CSV has no recognizable game ID column"
324 " — database will be empty");
325 }
326 continue;
327 }
328
329 // Parse data row
330 UMUDatabaseEntry entry;
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];
341
342 if (!entry.gameId.empty())
343 {
344 database_.push_back(entry);
345 }
346 }
347
348 Logger::info("Loaded {} entries from UMU database", database_.size());
349 }
350
351 UMUGameInfo lookupGameInDatabase(const std::string& gameId) const
352 {
353 UMUGameInfo info;
354 info.gameId = gameId;
355 info.found = false;
356
357 for (const auto& entry : database_)
358 {
359 if (entry.gameId == gameId)
360 {
361 info.found = true;
362 info.title = entry.title;
363 info.store = entry.store;
364 // Parse notes for fixes if available
365 if (!entry.notes.empty())
366 {
367 info.fixes.push_back(entry.notes);
368 }
369 return info;
370 }
371 }
372
373 return info;
374 }
375
376 std::vector<UMUGameInfo> searchDatabase(const std::string& query,
377 std::optional<UMUStore> storeFilter) const
378 {
379 std::vector<UMUGameInfo> results;
380
381 std::string lowerQuery = query;
382 std::transform(lowerQuery.begin(), lowerQuery.end(), lowerQuery.begin(),
383 [](unsigned char c) { return static_cast<char>(::tolower(c)); });
384
385 std::string storeFilterStr;
386 if (storeFilter.has_value())
387 {
388 storeFilterStr = UMULauncher::storeToString(storeFilter.value());
389 }
390
391 for (const auto& entry : database_)
392 {
393 // Apply store filter if specified
394 if (!storeFilterStr.empty())
395 {
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)
400 {
401 continue;
402 }
403 }
404
405 // Search in title, gameId, and codename
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)); });
415
416 if (lowerTitle.find(lowerQuery) != std::string::npos ||
417 lowerGameId.find(lowerQuery) != std::string::npos ||
418 lowerCodename.find(lowerQuery) != std::string::npos)
419 {
420 UMUGameInfo info;
421 info.gameId = entry.gameId;
422 info.title = entry.title;
423 info.store = entry.store;
424 info.found = true;
425 if (!entry.notes.empty())
426 {
427 info.fixes.push_back(entry.notes);
428 }
429 results.push_back(info);
430
431 // Limit results
432 if (results.size() >= 50)
433 {
434 break;
435 }
436 }
437 }
438
439 return results;
440 }
441
442 bool isAvailable_ = false;
443 std::string umuRunPath_;
444 std::string version_;
445 std::string runtimePath_;
446 bool hasGEProton_ = false;
447 bool hasUMUProton_ = false;
448 std::vector<UMUProtonVersion> protonVersions_;
449 std::vector<UMUDatabaseEntry> database_;
450};
451
452// ==============================================================================
453// Public Interface Implementation
454// ==============================================================================
455
456UMULauncher::UMULauncher() : impl_(std::make_unique<Impl>()) {}
457
458UMULauncher::~UMULauncher() = default;
459
461{
462 return impl_->isAvailable_;
463}
464
466{
467 UMUInstallStatus status;
468 status.isInstalled = impl_->isAvailable_;
469 status.umuRunPath = impl_->umuRunPath_;
470 status.version = impl_->version_;
471 status.runtimePath = impl_->runtimePath_;
472 status.hasGEProton = impl_->hasGEProton_;
473 status.hasUMUProton = impl_->hasUMUProton_;
474 status.availableProton = impl_->protonVersions_;
475 return status;
476}
477
478std::string UMULauncher::getUMURunPath() const
479{
480 return impl_->umuRunPath_;
481}
482
484{
485 impl_->refreshProtonVersions();
486}
487
488std::vector<UMUProtonVersion> UMULauncher::getAvailableProtonVersions() const
489{
490 return impl_->protonVersions_;
491}
492
493std::string UMULauncher::buildLaunchCommand(const UMULaunchConfig& config) const
494{
495 if (!impl_->isAvailable_)
496 {
497 Logger::error("UMU is not available");
498 return "";
499 }
500
501 std::ostringstream cmd;
502
503 // Environment variables
504 if (!config.winePrefix.empty())
505 {
506 cmd << "WINEPREFIX=" << ShellUtils::escapeArg(config.winePrefix) << " ";
507 }
508
509 // PROTONPATH
510 switch (config.protonPathMode)
511 {
513 cmd << "PROTONPATH=GE-Proton ";
514 break;
516 if (!config.customProtonPath.empty())
517 {
518 cmd << "PROTONPATH=" << ShellUtils::escapeArg(config.customProtonPath) << " ";
519 }
520 break;
522 // Find first available system Proton
523 for (const auto& p : impl_->protonVersions_)
524 {
525 if (p.isSystemProton)
526 {
527 cmd << "PROTONPATH=" << ShellUtils::escapeArg(p.path) << " ";
528 break;
529 }
530 }
531 break;
533 default:
534 // UMU-Proton is default, no need to set
535 break;
536 }
537
538 // GAMEID
539 if (!config.gameId.empty())
540 {
541 cmd << "GAMEID=" << ShellUtils::escapeArg(config.gameId) << " ";
542 }
543
544 // STORE
545 if (config.store != UMUStore::None || !config.customStore.empty())
546 {
547 std::string storeStr =
548 config.store == UMUStore::Custom ? config.customStore : storeToString(config.store);
549 if (!storeStr.empty())
550 {
551 cmd << "STORE=" << ShellUtils::escapeArg(storeStr) << " ";
552 }
553 }
554
555 // Debugging
556 if (config.enableUMULog)
557 {
558 cmd << "UMU_LOG=debug ";
559 }
560 if (config.enableProtonLog)
561 {
562 cmd << "PROTON_LOG=1 ";
563 }
564
565 // Advanced options
566 // UMU_NO_RUNTIME was a documented "disable container" toggle that umu-launcher
567 // never actually wired up (upstream issue #531) — removed so we don't lie to
568 // users. Callers that genuinely need to run a native binary inside the SLR
569 // can set UMU_NO_PROTON=1 via UMULaunchConfig::environmentVariables.
570 if (!config.protonVerb.empty())
571 {
572 cmd << "PROTON_VERB=" << ShellUtils::escapeArg(config.protonVerb) << " ";
573 }
574
575 // Custom environment variables
576 for (const auto& [key, value] : config.environmentVariables)
577 {
579 {
580 cmd << key << "=" << ShellUtils::escapeArg(value) << " ";
581 }
582 else
583 {
584 Logger::warn("[UMU] Skipping invalid env var name: {}", key);
585 }
586 }
587
588 // umu-run command
589 cmd << ShellUtils::escapeArg(impl_->umuRunPath_) << " ";
590
591 // Executable
592 cmd << ShellUtils::escapeArg(config.executable);
593
594 // Arguments
595 for (const auto& arg : config.arguments)
596 {
597 cmd << " " << ShellUtils::escapeArg(arg);
598 }
599
600 return cmd.str();
601}
602
604 std::map<std::string, std::string>& envVars,
605 std::vector<std::string>& command) const
606{
607 envVars.clear();
608 command.clear();
609
610 if (!impl_->isAvailable_)
611 return;
612
613 // Environment variables
614 if (!config.winePrefix.empty())
615 {
616 envVars["WINEPREFIX"] = config.winePrefix;
617 }
618
619 // PROTONPATH
620 switch (config.protonPathMode)
621 {
623 envVars["PROTONPATH"] = "GE-Proton";
624 break;
626 if (!config.customProtonPath.empty())
627 {
628 envVars["PROTONPATH"] = config.customProtonPath;
629 }
630 break;
632 for (const auto& p : impl_->protonVersions_)
633 {
634 if (p.isSystemProton)
635 {
636 envVars["PROTONPATH"] = p.path;
637 break;
638 }
639 }
640 break;
641 default:
642 break;
643 }
644
645 // GAMEID
646 if (!config.gameId.empty())
647 {
648 envVars["GAMEID"] = config.gameId;
649 }
650
651 // STORE
652 if (config.store != UMUStore::None || !config.customStore.empty())
653 {
654 std::string storeStr =
655 config.store == UMUStore::Custom ? config.customStore : storeToString(config.store);
656 if (!storeStr.empty())
657 {
658 envVars["STORE"] = storeStr;
659 }
660 }
661
662 // Debugging
663 if (config.enableUMULog)
664 {
665 envVars["UMU_LOG"] = "debug";
666 }
667 if (config.enableProtonLog)
668 {
669 envVars["PROTON_LOG"] = "1";
670 }
671
672 // Advanced — see buildLaunchCommand() for the UMU_NO_RUNTIME removal note.
673 if (!config.protonVerb.empty())
674 {
675 envVars["PROTON_VERB"] = config.protonVerb;
676 }
677
678 // Custom environment variables — validate key names to prevent corrupted env blocks
679 for (const auto& [key, value] : config.environmentVariables)
680 {
682 envVars[key] = value;
683 else
684 Logger::warn("[UMU] Skipping invalid env var name: {}", key);
685 }
686
687 // Command
688 command.push_back(impl_->umuRunPath_);
689 command.push_back(config.executable);
690 for (const auto& arg : config.arguments)
691 {
692 command.push_back(arg);
693 }
694}
695
696UMUGameInfo UMULauncher::lookupGame(const std::string& gameId) const
697{
698 // First try to find in the database
699 UMUGameInfo info = impl_->lookupGameInDatabase(gameId);
700
701 // If not found but has valid format, still mark as usable
702 if (!info.found && gameId.rfind("umu-", 0) == 0)
703 {
704 info.gameId = gameId;
705 info.title = gameId.substr(4); // Remove "umu-" prefix as rough title
706 // Not in database, but valid format - can still be used
707 // (protonfixes may not be available but game will run)
708 }
709
710 return info;
711}
712
713std::vector<UMUGameInfo> UMULauncher::searchGames(const std::string& query,
714 std::optional<UMUStore> store) const
715{
716 return impl_->searchDatabase(query, store);
717}
718
719std::string UMULauncher::suggestGameId(const std::string& gameName, UMUStore /* store */) const
720{
721 // Convert game name to umu-compatible ID
722 // Format: umu-<lowercase-name-with-hyphens>
723 std::string gameId = "umu-";
724
725 for (char c : gameName)
726 {
727 if (std::isalnum(static_cast<unsigned char>(c)))
728 {
729 gameId += static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
730 }
731 else if (c == ' ' || c == '_' || c == '-')
732 {
733 if (!gameId.empty() && gameId.back() != '-')
734 {
735 gameId += '-';
736 }
737 }
738 }
739
740 // Remove trailing hyphen
741 while (!gameId.empty() && gameId.back() == '-')
742 {
743 gameId.pop_back();
744 }
745
746 return gameId;
747}
748
750{
751 if (!impl_->isAvailable_)
752 {
753 Logger::error("UMU is not available for GE-Proton download");
754 return false;
755 }
756
757 // UMU downloads GE-Proton when PROTONPATH=GE-Proton is set and a game is launched.
758 // Run wineboot to trigger the runtime setup/download without launching a real game.
759 if (progressCallback)
760 {
761 progressCallback(0, "Initiating GE-Proton download via UMU...");
762 }
763
764 std::string cmd = "PROTONPATH=GE-Proton GAMEID=0 " + ShellUtils::escapeArg(impl_->umuRunPath_) +
765 " wineboot -u 2>&1";
766 int result = std::system(cmd.c_str());
767 bool success = (result != -1 && WIFEXITED(result) && WEXITSTATUS(result) == 0);
768
769 if (progressCallback)
770 {
771 progressCallback(100, success ? "GE-Proton ready" : "Download may have failed");
772 }
773
774 // Refresh versions
775 impl_->refreshProtonVersions();
776
777 return impl_->hasGEProton_;
778}
779
781{
782 if (!impl_->isAvailable_)
783 {
784 Logger::error("UMU is not available for UMU-Proton download");
785 return false;
786 }
787
788 // UMU-Proton is downloaded automatically on first run with default settings.
789 // Run wineboot to trigger the runtime setup/download without launching a real game.
790 if (progressCallback)
791 {
792 progressCallback(0, "Initiating UMU-Proton download...");
793 }
794
795 std::string cmd = "GAMEID=0 " + ShellUtils::escapeArg(impl_->umuRunPath_) + " wineboot -u 2>&1";
796 int result = std::system(cmd.c_str());
797 bool success = (result != -1 && WIFEXITED(result) && WEXITSTATUS(result) == 0);
798
799 if (progressCallback)
800 {
801 progressCallback(100, success ? "UMU-Proton ready" : "Download may have failed");
802 }
803
804 impl_->refreshProtonVersions();
805
806 return impl_->hasUMUProton_;
807}
808
810{
811 // Check if we have any Proton installed - if not, updates are "available"
812 if (impl_->protonVersions_.empty())
813 {
814 return true;
815 }
816
817 // Compare installed GE-Proton version against current known latest.
818 //
819 // This is a heuristic — for accurate checking, UMU handles its own update
820 // logic when PROTONPATH=GE-Proton is used at launch time. We only flag
821 // updates here when the installed major is clearly behind the current
822 // mainline so the UI can nudge the user; we deliberately do NOT call out
823 // patch-level differences (those churn weekly).
824 //
825 // Maintenance: bump kCurrentGEProtonMajor when GE cuts a new major.
826 // Last verified: 2026-05-02 — current is GE-Proton10 (10-34, 2026-03).
827 constexpr int kCurrentGEProtonMajor = 10;
828 constexpr int kFutureGEProtonMajorWarn = kCurrentGEProtonMajor + 2;
829
830 for (const auto& version : impl_->protonVersions_)
831 {
832 if (version.isGEProton)
833 {
834 // GE-Proton follows pattern GE-ProtonX-Y where X is major, Y is minor
835 std::regex versionRegex(R"(GE-Proton(\d+)-(\d+))");
836 std::smatch match;
837 if (std::regex_search(version.name, match, versionRegex))
838 {
839 int major = 0;
840 try
841 {
842 major = std::stoi(match[1].str());
843 }
844 catch (const std::exception&)
845 {
846 major = 0;
847 }
848
849 if (major < kCurrentGEProtonMajor)
850 {
851 return true;
852 }
853 if (major >= kFutureGEProtonMajorWarn)
854 {
855 // Loud warning so a stale heuristic surfaces in logs
856 // instead of silently mismatching a future GE-Proton
857 // major that may have changed PROTONPATH semantics.
858 Logger::warn("[UMU] Installed GE-Proton major {} is newer than the audited "
859 "current ({}); update kCurrentGEProtonMajor in umu_launcher.cpp.",
860 major, kCurrentGEProtonMajor);
861 }
862 }
863 // If we have current (or newer) GE-Proton, no immediate updates needed
864 return false;
865 }
866 }
867
868 // No GE-Proton installed, suggest getting it
869 return true;
870}
871
872std::string UMULauncher::getDefaultPrefixPath(const std::string& gameId) const
873{
874 const char* home = std::getenv("HOME");
875 if (!home)
876 return "";
877
878 std::string id = gameId.empty() ? "umu-default" : gameId;
879 return std::string(home) + "/Games/umu/" + id;
880}
881
882bool UMULauncher::prefixExists(const std::string& prefixPath) const
883{
884 return fs::exists(prefixPath) && fs::is_directory(prefixPath);
885}
886
887bool UMULauncher::createPrefix(const std::string& prefixPath, const std::string& protonPath)
888{
889 if (!impl_->isAvailable_)
890 {
891 Logger::error("UMU is not available for prefix creation");
892 return false;
893 }
894
895 // Create prefix by running wineboot
896 std::ostringstream cmd;
897 cmd << "WINEPREFIX=" << ShellUtils::escapeArg(prefixPath) << " ";
898
899 if (!protonPath.empty())
900 {
901 cmd << "PROTONPATH=" << ShellUtils::escapeArg(protonPath) << " ";
902 }
903
904 cmd << ShellUtils::escapeArg(impl_->umuRunPath_) << " wineboot -u 2>&1";
905
906 Logger::info("Creating Wine prefix at {}", prefixPath);
907 int result = std::system(cmd.str().c_str());
908
909 return result != -1 && WIFEXITED(result) && WEXITSTATUS(result) == 0 && fs::exists(prefixPath);
910}
911
912bool UMULauncher::runWinetricks(const std::string& prefixPath,
913 const std::vector<std::string>& verbs,
914 const std::string& protonPath,
915 const ProgressCallback& progressCallback)
916{
917 if (!impl_->isAvailable_ || verbs.empty())
918 {
919 return false;
920 }
921
922 // Build winetricks command
923 std::ostringstream verbList;
924 for (size_t i = 0; i < verbs.size(); ++i)
925 {
926 if (i > 0)
927 verbList << " ";
928 verbList << ShellUtils::escapeArg(verbs[i]);
929 }
930
931 std::ostringstream cmd;
932 cmd << "WINEPREFIX=" << ShellUtils::escapeArg(prefixPath) << " ";
933
934 if (!protonPath.empty())
935 {
936 cmd << "PROTONPATH=" << ShellUtils::escapeArg(protonPath) << " ";
937 }
938 else
939 {
940 cmd << "PROTONPATH=GE-Proton ";
941 }
942
943 cmd << ShellUtils::escapeArg(impl_->umuRunPath_) << " winetricks " << verbList.str() << " 2>&1";
944
945 if (progressCallback)
946 {
947 progressCallback(0, "Running winetricks: " + verbList.str());
948 }
949
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);
953
954 if (progressCallback)
955 {
956 progressCallback(100, success ? "Winetricks completed" : "Winetricks failed");
957 }
958
959 return success;
960}
961
963{
964 switch (store)
965 {
966 case UMUStore::Steam:
967 return "steam";
968 case UMUStore::EGS:
969 return "egs";
970 case UMUStore::GOG:
971 return "gog";
972 case UMUStore::Amazon:
973 return "amazon";
975 return "ubisoft";
976 case UMUStore::EA:
977 return "ea";
978 case UMUStore::Humble:
979 return "humble";
980 case UMUStore::Itch:
981 return "itch";
982 case UMUStore::None:
983 case UMUStore::Custom:
984 default:
985 return "";
986 }
987}
988
990{
991 std::string lower = str;
992 std::transform(lower.begin(), lower.end(), lower.begin(),
993 [](unsigned char c) { return static_cast<char>(::tolower(c)); });
994
995 if (lower == "steam")
996 return UMUStore::Steam;
997 if (lower == "egs" || lower == "epic")
998 return UMUStore::EGS;
999 if (lower == "gog")
1000 return UMUStore::GOG;
1001 if (lower == "amazon")
1002 return UMUStore::Amazon;
1003 if (lower == "ubisoft" || lower == "uplay")
1004 return UMUStore::Ubisoft;
1005 if (lower == "ea" || lower == "origin")
1006 return UMUStore::EA;
1007 if (lower == "humble")
1008 return UMUStore::Humble;
1009 if (lower == "itch" || lower == "itchio")
1010 return UMUStore::Itch;
1011
1012 return UMUStore::None;
1013}
1014
1015std::string umuStoreName(UMUStore store)
1016{
1017 switch (store)
1018 {
1019 case UMUStore::Steam:
1020 return "Steam";
1021 case UMUStore::EGS:
1022 return "Epic Games Store";
1023 case UMUStore::GOG:
1024 return "GOG";
1025 case UMUStore::Amazon:
1026 return "Amazon Games";
1027 case UMUStore::Ubisoft:
1028 return "Ubisoft Connect";
1029 case UMUStore::EA:
1030 return "EA App";
1031 case UMUStore::Humble:
1032 return "Humble Bundle";
1033 case UMUStore::Itch:
1034 return "itch.io";
1035 case UMUStore::Custom:
1036 return "Custom";
1037 case UMUStore::None:
1038 default:
1039 return "Unknown";
1040 }
1041}
static void info(const std::string &message, Args &&... args)
Log info message (general information).
Definition logger.h:108
static void debug(const std::string &message, Args &&... args)
Log debug message (verbose development info).
Definition logger.h:100
static void error(const std::string &message, Args &&... args)
Log error message (recoverable failure).
Definition logger.h:124
static void warn(const std::string &message, Args &&... args)
Log warning message (non-critical issue).
Definition logger.h:116
static std::string escapeArg(const std::string &arg)
Escape a string for safe use as a shell argument.
Definition shell_utils.h:65
static bool isValidEnvName(const std::string &name)
Validate an environment variable name.
UMUGameInfo lookupGameInDatabase(const std::string &gameId) const
std::vector< UMUGameInfo > searchDatabase(const std::string &query, std::optional< UMUStore > storeFilter) const
std::string umuRunPath_
std::vector< UMUDatabaseEntry > database_
std::string runtimePath_
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
std::string gameId
std::string title
std::string notes
std::string codename
std::string store
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).
@ Itch
itch.io
@ None
No specific store (generic fixes only).
@ EGS
Epic Games Store.
@ Custom
Custom store identifier.
@ EA
EA App / Origin.
@ GOG
GOG.com.
@ Humble
Humble Bundle.
@ Amazon
Amazon Games.
@ 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.