you can now activate a steam managed bottle using "steam:$APPID"
This commit is contained in:
		
							
								
								
									
										93
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,93 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "files.associations": {
 | 
				
			||||||
 | 
					        "*.wsgi": "python",
 | 
				
			||||||
 | 
					        "*.s": "nasm",
 | 
				
			||||||
 | 
					        "*.cog": "cpp",
 | 
				
			||||||
 | 
					        "algorithm": "cpp",
 | 
				
			||||||
 | 
					        "cmath": "cpp",
 | 
				
			||||||
 | 
					        "any": "cpp",
 | 
				
			||||||
 | 
					        "array": "cpp",
 | 
				
			||||||
 | 
					        "atomic": "cpp",
 | 
				
			||||||
 | 
					        "hash_map": "cpp",
 | 
				
			||||||
 | 
					        "strstream": "cpp",
 | 
				
			||||||
 | 
					        "bit": "cpp",
 | 
				
			||||||
 | 
					        "*.tcc": "cpp",
 | 
				
			||||||
 | 
					        "bitset": "cpp",
 | 
				
			||||||
 | 
					        "cctype": "cpp",
 | 
				
			||||||
 | 
					        "cfenv": "cpp",
 | 
				
			||||||
 | 
					        "charconv": "cpp",
 | 
				
			||||||
 | 
					        "chrono": "cpp",
 | 
				
			||||||
 | 
					        "clocale": "cpp",
 | 
				
			||||||
 | 
					        "codecvt": "cpp",
 | 
				
			||||||
 | 
					        "compare": "cpp",
 | 
				
			||||||
 | 
					        "complex": "cpp",
 | 
				
			||||||
 | 
					        "concepts": "cpp",
 | 
				
			||||||
 | 
					        "condition_variable": "cpp",
 | 
				
			||||||
 | 
					        "coroutine": "cpp",
 | 
				
			||||||
 | 
					        "csetjmp": "cpp",
 | 
				
			||||||
 | 
					        "csignal": "cpp",
 | 
				
			||||||
 | 
					        "cstdarg": "cpp",
 | 
				
			||||||
 | 
					        "cstddef": "cpp",
 | 
				
			||||||
 | 
					        "cstdint": "cpp",
 | 
				
			||||||
 | 
					        "cstdio": "cpp",
 | 
				
			||||||
 | 
					        "cstdlib": "cpp",
 | 
				
			||||||
 | 
					        "cstring": "cpp",
 | 
				
			||||||
 | 
					        "ctime": "cpp",
 | 
				
			||||||
 | 
					        "cwchar": "cpp",
 | 
				
			||||||
 | 
					        "cwctype": "cpp",
 | 
				
			||||||
 | 
					        "deque": "cpp",
 | 
				
			||||||
 | 
					        "forward_list": "cpp",
 | 
				
			||||||
 | 
					        "list": "cpp",
 | 
				
			||||||
 | 
					        "map": "cpp",
 | 
				
			||||||
 | 
					        "set": "cpp",
 | 
				
			||||||
 | 
					        "string": "cpp",
 | 
				
			||||||
 | 
					        "unordered_map": "cpp",
 | 
				
			||||||
 | 
					        "unordered_set": "cpp",
 | 
				
			||||||
 | 
					        "vector": "cpp",
 | 
				
			||||||
 | 
					        "exception": "cpp",
 | 
				
			||||||
 | 
					        "functional": "cpp",
 | 
				
			||||||
 | 
					        "iterator": "cpp",
 | 
				
			||||||
 | 
					        "memory": "cpp",
 | 
				
			||||||
 | 
					        "memory_resource": "cpp",
 | 
				
			||||||
 | 
					        "numeric": "cpp",
 | 
				
			||||||
 | 
					        "optional": "cpp",
 | 
				
			||||||
 | 
					        "random": "cpp",
 | 
				
			||||||
 | 
					        "ratio": "cpp",
 | 
				
			||||||
 | 
					        "regex": "cpp",
 | 
				
			||||||
 | 
					        "source_location": "cpp",
 | 
				
			||||||
 | 
					        "string_view": "cpp",
 | 
				
			||||||
 | 
					        "system_error": "cpp",
 | 
				
			||||||
 | 
					        "tuple": "cpp",
 | 
				
			||||||
 | 
					        "type_traits": "cpp",
 | 
				
			||||||
 | 
					        "utility": "cpp",
 | 
				
			||||||
 | 
					        "format": "cpp",
 | 
				
			||||||
 | 
					        "fstream": "cpp",
 | 
				
			||||||
 | 
					        "future": "cpp",
 | 
				
			||||||
 | 
					        "initializer_list": "cpp",
 | 
				
			||||||
 | 
					        "iomanip": "cpp",
 | 
				
			||||||
 | 
					        "iosfwd": "cpp",
 | 
				
			||||||
 | 
					        "iostream": "cpp",
 | 
				
			||||||
 | 
					        "istream": "cpp",
 | 
				
			||||||
 | 
					        "limits": "cpp",
 | 
				
			||||||
 | 
					        "mutex": "cpp",
 | 
				
			||||||
 | 
					        "new": "cpp",
 | 
				
			||||||
 | 
					        "numbers": "cpp",
 | 
				
			||||||
 | 
					        "ostream": "cpp",
 | 
				
			||||||
 | 
					        "ranges": "cpp",
 | 
				
			||||||
 | 
					        "semaphore": "cpp",
 | 
				
			||||||
 | 
					        "shared_mutex": "cpp",
 | 
				
			||||||
 | 
					        "span": "cpp",
 | 
				
			||||||
 | 
					        "sstream": "cpp",
 | 
				
			||||||
 | 
					        "stdexcept": "cpp",
 | 
				
			||||||
 | 
					        "stdfloat": "cpp",
 | 
				
			||||||
 | 
					        "stop_token": "cpp",
 | 
				
			||||||
 | 
					        "streambuf": "cpp",
 | 
				
			||||||
 | 
					        "text_encoding": "cpp",
 | 
				
			||||||
 | 
					        "thread": "cpp",
 | 
				
			||||||
 | 
					        "cinttypes": "cpp",
 | 
				
			||||||
 | 
					        "typeindex": "cpp",
 | 
				
			||||||
 | 
					        "typeinfo": "cpp",
 | 
				
			||||||
 | 
					        "valarray": "cpp",
 | 
				
			||||||
 | 
					        "variant": "cpp"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -21,7 +21,7 @@ void cellar::bottles::switch_active_bottle(int argc, vector<string> argv) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    string homepath = getenv("HOME");
 | 
					    string homepath = getenv("HOME");
 | 
				
			||||||
    string bottlepath = homepath + "/.wine";
 | 
					    string bottlepath = homepath + "/.wine";
 | 
				
			||||||
    string targetpath = homepath + "/.local/share/cellar/bottles/" + argv[1];
 | 
					    string targetpath = cellar::bottles::resolve_bottle(argv[1]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    file_status targetstatus = symlink_status(targetpath);
 | 
					    file_status targetstatus = symlink_status(targetpath);
 | 
				
			||||||
    if (!exists(targetstatus)) {
 | 
					    if (!exists(targetstatus)) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -85,13 +85,20 @@ string cellar::bottles::resolve_bottle(string bottlechoice) {
 | 
				
			|||||||
    if (bottlechoice.substr(0,1) == "/" || bottlechoice.substr(0,1) == ".") { // absolute or relative path
 | 
					    if (bottlechoice.substr(0,1) == "/" || bottlechoice.substr(0,1) == ".") { // absolute or relative path
 | 
				
			||||||
        result = bottlechoice;
 | 
					        result = bottlechoice;
 | 
				
			||||||
    } else if (bottlechoice.substr(0,1) == "~") { // "absolute" path in home directory, not expanded by the shell for some reason (i've seen some shit)
 | 
					    } else if (bottlechoice.substr(0,1) == "~") { // "absolute" path in home directory, not expanded by the shell for some reason (i've seen some shit)
 | 
				
			||||||
        // this is a naive replacement and will fail if the user tries something like ~nick/.wine
 | 
					        // this is a naive replacement and will fail if the user tries something like ~nicole/.wine
 | 
				
			||||||
        // i'm figuring at that point if you're doing that, you'll also recognize if your shell
 | 
					        // i'm figuring at that point if you're doing that, you'll also recognize if your shell
 | 
				
			||||||
        // isn't actually expanding your path...
 | 
					        // isn't actually expanding your path...
 | 
				
			||||||
        bottlechoice.replace(0,1,getenv("HOME"));
 | 
					        bottlechoice.replace(0,1,getenv("HOME"));
 | 
				
			||||||
        // or at least you'll think to use verbose mode to make sure it's loading the right directory
 | 
					        // or at least you'll think to use verbose mode to make sure it's loading the right directory
 | 
				
			||||||
        output::warning("your shell didn't expand your given path properly, doing a naive replacement", true);
 | 
					        output::warning("your shell didn't expand your given path properly, doing a naive replacement", true);
 | 
				
			||||||
        result = bottlechoice;
 | 
					        result = bottlechoice;
 | 
				
			||||||
 | 
					#ifdef ENABLE_STEAM
 | 
				
			||||||
 | 
					    } else if (bottlechoice.substr(0,6) == "steam:") { // steam bottles
 | 
				
			||||||
 | 
					        string str_appid = bottlechoice.substr(6);
 | 
				
			||||||
 | 
					        unsigned long uint_appid = std::stoul(str_appid);
 | 
				
			||||||
 | 
					        auto steambottle = cellar::steam::app_bottle(uint_appid);
 | 
				
			||||||
 | 
					        result = steambottle.path;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        string homepath = getenv("HOME");
 | 
					        string homepath = getenv("HOME");
 | 
				
			||||||
        string fullbottlepath = homepath + "/.local/share/cellar/bottles" + bottlechoice;
 | 
					        string fullbottlepath = homepath + "/.local/share/cellar/bottles" + bottlechoice;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,13 +38,24 @@ std::map<std::string, cellar::bottles::Bottle> cellar::steam::get_app_bottles()
 | 
				
			|||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                auto curbottle = cellar::bottles::Bottle(pth_appid.string());
 | 
					                auto curbottle = cellar::bottles::Bottle((pth_appid / "pfx").string());
 | 
				
			||||||
                curbottle.set_config("description", str_gamename);
 | 
					                curbottle.set_config("name", str_gamename);
 | 
				
			||||||
                curbottle.save_config();
 | 
					                curbottle.save_config();
 | 
				
			||||||
                result[std::string("proton-" + pth_appid.filename().string())] = curbottle;
 | 
					                result[std::string("steam:" + pth_appid.filename().string())] = curbottle;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return result;
 | 
					    return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cellar::bottles::Bottle cellar::steam::app_bottle(unsigned appid) {
 | 
				
			||||||
 | 
					    string str_appid = std::to_string(appid);
 | 
				
			||||||
 | 
					    string str_prefix = std::string("steam:") + str_appid;
 | 
				
			||||||
 | 
					    auto steambottles = get_app_bottles();
 | 
				
			||||||
 | 
					    if (steambottles.find(str_prefix) == steambottles.end()) {
 | 
				
			||||||
 | 
					        throw std::range_error("steam is not currently managing a valid prefix for " + std::to_string(appid));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return steambottles.at(str_prefix);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user